Add project files.

This commit is contained in:
2018-06-25 21:48:45 -04:00
parent b04a25689b
commit 3c1b7d28e8
425 changed files with 35333 additions and 0 deletions
@@ -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;
}
@@ -0,0 +1,72 @@
#ifndef _CAUDIO_HPP_
#define _CAUDIO_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_mixer.h>
/*** 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_
@@ -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()
{}
@@ -0,0 +1,47 @@
#ifndef _CMUSIC_HPP_
#define _CMUSIC_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_mixer.h>
/*** 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_
@@ -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;
}
}
@@ -0,0 +1,91 @@
#ifndef _CSOUND_HPP_
#define _CSOUND_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_mixer.h>
/*** 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_
@@ -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;
}
}
@@ -0,0 +1,76 @@
#ifndef _CEVENT_HPP_
#define _CEVENT_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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<EventEngine::cEvent*>::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<EventEngine::cEvent*>::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<EventEngine::cEvent*>& cEventControl::GetEvents()
{
return m_children;
}
///Sets
///Gets
/* Gets return true if Event was initialized */
const bool cEventControl::IsInit() const
{
return true;
}
@@ -0,0 +1,53 @@
#ifndef _CEVENTCONTROL_HPP_
#define _CEVENTCONTROL_HPP_
/*** C++ STL Files ***/
#include <vector>
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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<EventEngine::cEvent*>& GetEvents();
///Sets
///Gets
/* Gets return true if Event was initialized */
const bool IsInit() const;
private:
std::vector<cEvent*> m_children;
static cEventControl* sp_inst;// = nullptr
};/// END CLASS DEFINITION cEventControl
}/// END NAMESPACE DEFINITION EventEngine
#endif/// END IFNDEF _CEVENTCONTROL_HPP_
@@ -0,0 +1,116 @@
#include "cGFX.hpp"
/*** SDL Header Files ***/
#include <SDL2_gfxPrimitives.h>
/*** 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;
}
@@ -0,0 +1,49 @@
#ifndef _CGFX_HPP_
#define _CGFX_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL2_rotozoom.h>
/*** 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_
@@ -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_
@@ -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;
}
@@ -0,0 +1,47 @@
#ifndef _GUIUTILITY_HPP_
#define _GUIUTILITY_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -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_
@@ -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;
}
@@ -0,0 +1,28 @@
#ifndef _CTEXTURE_HPP_
#define _CTEXTURE_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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<cString> 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<cString> 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<cString> 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<cString> 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);
}
@@ -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_
@@ -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;
}
@@ -0,0 +1,45 @@
#ifndef _CBOXSIZER_HPP_
#define _CBOXSIZER_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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);
}
@@ -0,0 +1,63 @@
#ifndef _CBUTTON_HPP_
#define _CBUTTON_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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<GUIHelpers::cObject*>::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<GUIEngine::cWindow*>& cGUI::GetObjects()
{
return m_children;
}
void cGUI::Display()
{
//m_obj->Display();
std::vector<GUIEngine::cWindow*>::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;
}
@@ -0,0 +1,105 @@
#ifndef _CGUI_HPP_
#define _CGUI_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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<GUIEngine::cWindow*>& 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<GUIEngine::cWindow*> m_children;
};/// END CLASS DEFINITION cGUI
}/// END NAMESPACE DEFINITION GUIEngine
#endif/// END IFNDEF _CGUI_HPP_
@@ -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);
}
}
@@ -0,0 +1,64 @@
#ifndef _CLABEL_HPP_
#define _CLABEL_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,52 @@
#ifndef _CLAYOUT_HPP_
#define _CLAYOUT_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,42 @@
#ifndef _CPANEL_HPP_
#define _CPANEL_HPP_
/** C++ Header Files **/
#include <vector>
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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()
{}
@@ -0,0 +1,62 @@
#ifndef _CTEXTBUTTON_HPP_
#define _CTEXTBUTTON_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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<cWindow*>::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<cWindow*>::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<cWindow*>::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<cWindow*>::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<cWindow*>::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*>& 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);
}
}
@@ -0,0 +1,126 @@
#ifndef _CWINDOW_HPP_
#define _CWINDOW_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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<cWindow*>& 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<cWindow*> m_children;
cWindow* mp_parent;// = nullptr;
};/// END CLASS DEFINITION cBoxSizer
}/// END NAMESPACE DEFINITION GUIEngine
#endif/// END IFNDEF _CBOXSIZER_HPP_
@@ -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<InputEngine::cKeyboard*>::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<InputEngine::cKeyboard*>::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<InputEngine::cKeyboard*>::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;
}
@@ -0,0 +1,71 @@
#ifndef _CINPUT_HPP_
#define _CINPUT_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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<InputEngine::cKeyboard*> m_keyboards;
SDL_Event m_event;
static cInput* sp_inst;// = nullptr
};/// END CLASS DEFINITION cInput
}/// END NAMESPACE DEFINITION InputEngine
#endif/// END IFNDEF _CINPUT_HPP_
@@ -0,0 +1,10 @@
#include "cJoystick.hpp"
using InputEngine::cJoystick;
cJoystick::cJoystick()
{}
/*virtual*/ cJoystick::~cJoystick()
{}
@@ -0,0 +1,38 @@
#ifndef _CJOYSTICK_HPP_
#define _CJOYSTICK_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,37 @@
#ifndef _CKEY_HPP_
#define _CKEY_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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<InputEngine::cKey*>::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<InputEngine::cKey*>::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;
}
@@ -0,0 +1,55 @@
#ifndef _CKEYBOARD_HPP_
#define _CKEYBOARD_HPP_
/*** C++ STL Files ***/
#include <vector>
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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<InputEngine::cKey*>;
EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::vector<InputEngine::cKey*, std::allocator<InputEngine::cKey*> >;
/*#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<InputEngine::cKey*> m_keys;
};/// END CLASS DEFINITION cKeyboard
}/// END NAMESPACE DEFINITION InputEngine
#endif/// END IFNDEF _CKEYBOARD_HPP_
@@ -0,0 +1,11 @@
#include "cMouse.hpp"
using InputEngine::cMouse;
cMouse::cMouse()
{}
cMouse::~cMouse()
{}
@@ -0,0 +1,21 @@
#ifndef _CMOUSE_HPP_
#define _CMOUSE_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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<char>(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;
}
@@ -0,0 +1,50 @@
#ifndef _CTEXTINPUT_HPP_
#define _CTEXTINPUT_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,29 @@
#ifndef _VECTOR2_HPP_
#define _VECTOR2_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,31 @@
#ifndef _VECTOR3_HPP_
#define _VECTOR3_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,35 @@
#ifndef _VECTOR4_HPP_
#define _VECTOR4_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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 );
}
@@ -0,0 +1,50 @@
#ifndef _CCOLLISION_HPP_
#define _CCOLLISION_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -0,0 +1,47 @@
#include "cRandom.hpp"
/*** ANSI C Header Files ***/
#include <stdlib.h>
#include <time.h>
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);
}
@@ -0,0 +1,32 @@
#ifndef _CRANDOM_HPP_
#define _CRANDOM_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,39 @@
#ifndef _IVECTOR2_HPP_
#define _IVECTOR2_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,37 @@
#ifndef _IVECTOR3_HPP_
#define _IVECTOR3_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,39 @@
#ifndef _IVECTOR4_HPP_
#define _IVECTOR4_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -0,0 +1,11 @@
// Static Model
#include "cNetwork.hpp"
using NetworkEngine::cNetwork;
cNetwork::cNetwork()
{}
cNetwork::~cNetwork()
{}
@@ -0,0 +1,19 @@
#ifndef _CNETWORK_HPP_
#define _CNETWORK_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
///#include <SDL/SDL_net.h> ///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_
@@ -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;
}
@@ -0,0 +1,28 @@
#ifndef _CFONTHOLDER_HPP_
#define _CFONTHOLDER_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_ttf.h>
/*** 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_
@@ -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<cFontHolder*>::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();
}
@@ -0,0 +1,75 @@
#ifndef _CFONT_HPP_
#define _CFONT_HPP_
/*** ANSI C++ Header Files ***/
#include <vector>
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_ttf.h>
/*** 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<TextTypeHelpers::cFontHolder*>;
EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::vector<TextTypeHelpers::cFontHolder*, std::allocator<TextTypeHelpers::cFontHolder*> >;
/*#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<TextTypeHelpers::cFontHolder*> 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_
@@ -0,0 +1,206 @@
#include "cText.hpp"
/*** SDL Header Files ***/
#include <SDL2_gfxPrimitives.h>
#include <SDL2_gfxPrimitives_font.h>
#include <SDL2_rotozoom.h>
/*** 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);
}
}
}
@@ -0,0 +1,92 @@
#ifndef _CTEXT_HPP_
#define _CTEXT_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_ttf.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,40 @@
#ifndef _CTEXTTYPE_HPP_
#define _CTEXTTYPE_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_ttf.h>
/*** 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_
@@ -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 != &copy)
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;
}
@@ -0,0 +1,68 @@
#ifndef _CTIMING_HPP_
#define _CTIMING_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include <dllExport.h>
#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_
@@ -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();
}
@@ -0,0 +1,68 @@
#ifndef _CTROOPERENGINECORE_HPP_
#define _CTROOPERENGINECORE_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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);
}
@@ -0,0 +1,14 @@
#ifndef __MSUNIX__
#define __MSUNIX__
#define _MSUNIX_VERSION "1.0.0"
#include <cstdio>
#include <cstdlib>
#include <cstdarg>
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__
@@ -0,0 +1,423 @@
#include "cString.hpp"
/*** ANSI C Header Files ***/
#include <stdlib.h> /* 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> cString::split(const char match) const
{
const char match_s[2] = { match, 0 };
return split(match_s, -1);
}
const std::vector<cString> cString::split(const char* match) const
{
return split(match, -1);
}
const std::vector<cString> cString::split(const char* match, int max_split) const
{
std::vector<cString> 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;
}
@@ -0,0 +1,85 @@
#ifndef _CSTRING_HPP_
#define _CSTRING_HPP_
/*** C++ STL Files ***/
#include <string>
#include <vector>
/*** SDL Header Files ***/
#include <SDL.h>
/*** DLL Header File ***/
#include "dllExport.h"
/*#pragma warning (disable : 4231)*/
EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::allocator<char>;
EXPIMP_TEMPLATE template class EXPORT_FROM_MYDLL std::basic_string<char>;
/*#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<cString> split(const char match) const;
const std::vector<cString> split(const char* match) const;
const std::vector<cString> 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_
@@ -0,0 +1,132 @@
#include "cUtility.hpp"
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_ttf.h>
#include <SDL_image.h>
#include <SDL_mixer.h>
#include <SDL_net.h>
using UtilityEngine::cUtility;
/*static*/ cUtility* cUtility::sp_inst = nullptr;
//private:
cUtility::cUtility()
{}
cUtility::~cUtility()
{}
//public:
// cUtility& cUtility::operator=( const cUtility& copy )
// {
// if (this != &copy)
// {
// }
//
// 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);
}
@@ -0,0 +1,67 @@
#ifndef _CUTILITY_HPP_
#define _CUTILITY_HPP_
/*** ANSI C Header Files ***/
#include <stdio.h> //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_
@@ -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;
}
@@ -0,0 +1,70 @@
#ifndef _CANIMATEDSPRITE_HPP_
#define _CANIMATEDSPRITE_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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);
}
@@ -0,0 +1,71 @@
#ifndef _CCAMERA_HPP_
#define _CCAMERA_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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<cSprite*> m_sprites;
//LinkList::cLList m_sprites;
};/// END CLASS DEFINITION cCamera
}/// END NAMESPACE DEFINITION VideoEngine
#endif/// END IFNDEF _CCAMERA_HPP_
@@ -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;
}
}
@@ -0,0 +1,112 @@
#ifndef _CIMAGE_HPP_
#define _CIMAGE_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
#include <SDL_image.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,71 @@
#ifndef _CRENDERER_HPP_
#define _CRENDERER_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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 != &copy)
{
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;
}
@@ -0,0 +1,116 @@
#ifndef _CSPRITE_HPP_
#define _CSPRITE_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
@@ -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;
}
@@ -0,0 +1,138 @@
#ifndef _CVIDEO_HPP_
#define _CVIDEO_HPP_
/*** SDL Header Files ***/
#include <SDL.h>
/*** 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_
+226
View File
@@ -0,0 +1,226 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="UTest|Win32">
<Configuration>UTest</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B6513FAA-8BDE-45AA-9F1E-326BCBE5D2E8}</ProjectGuid>
<RootNamespace>TrooperEngineDLL</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<UseOfMfc>false</UseOfMfc>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='UTest|Win32'">
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<AdditionalOptions>/MP %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(TINYXML);$(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>false</TreatWarningAsError>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<PreprocessorDefinitions>%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(TargetName).dll</OutputFile>
<AdditionalLibraryDirectories>../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)</AdditionalLibraryDirectories>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>NotSet</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<ImportLibrary>
</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>Full</Optimization>
<AdditionalIncludeDirectories>../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)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level4</WarningLevel>
<TreatWarningAsError>true</TreatWarningAsError>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>sdl.lib;sdlmain.lib;sdl_image.lib;sdl_ttf.lib;sdl_mixer.lib;LinkList.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)TrooperEngine.dll</OutputFile>
<AdditionalLibraryDirectories>../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)</AdditionalLibraryDirectories>
<GenerateDebugInformation>false</GenerateDebugInformation>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='UTest|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(SDL2_gfx);dllExportFiles;$(SDL2_net)\include;$(SDL2_ttf)\include;$(SDL2_mixer)\include;$(SDL2_image)\include;$(SDL2)\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="dllExportFiles\CompileSettings.h" />
<ClInclude Include="dllExportFiles\dllExport.h" />
<ClInclude Include="dllExportFiles\TrooperEngine.hpp" />
<ClInclude Include="TrooperEngine\AudioEngine\cAudio.hpp" />
<ClInclude Include="TrooperEngine\AudioEngine\cMusic.hpp" />
<ClInclude Include="TrooperEngine\AudioEngine\cSound.hpp" />
<ClInclude Include="TrooperEngine\EventEngine\cEvent.hpp" />
<ClInclude Include="TrooperEngine\EventEngine\cEventControl.hpp" />
<ClInclude Include="TrooperEngine\FXEngine\cGFX.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\cBoxSizer.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\cButton.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\cGUI.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\cLayout.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\cPanel.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\cLabel.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\cTextButton.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\cWindow.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cTexture.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cObject.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\Enums.hpp" />
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\GUIUtility.hpp" />
<ClInclude Include="TrooperEngine\InputEngine\cInput.hpp" />
<ClInclude Include="TrooperEngine\InputEngine\cJoystick.hpp" />
<ClInclude Include="TrooperEngine\InputEngine\cKey.hpp" />
<ClInclude Include="TrooperEngine\InputEngine\cKeyboard.hpp" />
<ClInclude Include="TrooperEngine\InputEngine\cMouse.hpp" />
<ClInclude Include="TrooperEngine\InputEngine\cTextInput.hpp" />
<ClInclude Include="TrooperEngine\MathEngine\cCollision.hpp" />
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector2.hpp" />
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector3.hpp" />
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector4.hpp" />
<ClInclude Include="TrooperEngine\MathEngine\Vector\Vector2.hpp" />
<ClInclude Include="TrooperEngine\MathEngine\Vector\Vector3.hpp" />
<ClInclude Include="TrooperEngine\MathEngine\Vector\Vector4.hpp" />
<ClInclude Include="TrooperEngine\TextTypeEngine\cFont.hpp" />
<ClInclude Include="TrooperEngine\TextTypeEngine\cText.hpp" />
<ClInclude Include="TrooperEngine\TextTypeEngine\cTextType.hpp" />
<ClInclude Include="TrooperEngine\TextTypeEngine\TextTypeHelpers\cFontHolder.hpp" />
<ClInclude Include="TrooperEngine\UtilityEngine\cString.hpp" />
<ClInclude Include="TrooperEngine\UtilityEngine\cUtility.hpp" />
<ClInclude Include="TrooperEngine\UtilityEngine\MSUNIX\msunix.hpp" />
<ClInclude Include="TrooperEngine\VideoEngine\cAnimatedSprite.hpp" />
<ClInclude Include="TrooperEngine\VideoEngine\cCamera.hpp" />
<ClInclude Include="TrooperEngine\VideoEngine\cImage.hpp" />
<ClInclude Include="TrooperEngine\VideoEngine\cRenderer.hpp" />
<ClInclude Include="TrooperEngine\VideoEngine\cSprite.hpp" />
<ClInclude Include="TrooperEngine\VideoEngine\cVideo.hpp" />
<ClInclude Include="TrooperEngine\TimingEngine\cTiming.hpp" />
<ClInclude Include="TrooperEngine\NetworkEngine\cNetwork.hpp" />
<ClInclude Include="TrooperEngine\TrooperEngineCore\cTrooperEngineCore.hpp" />
<ClInclude Include="TrooperEngine\MathEngine\cRandom.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="TrooperEngine\AudioEngine\cAudio.cpp" />
<ClCompile Include="TrooperEngine\AudioEngine\cMusic.cpp" />
<ClCompile Include="TrooperEngine\AudioEngine\cSound.cpp" />
<ClCompile Include="TrooperEngine\EventEngine\cEvent.cpp" />
<ClCompile Include="TrooperEngine\EventEngine\cEventControl.cpp" />
<ClCompile Include="TrooperEngine\FXEngine\cGFX.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\cBoxSizer.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\cButton.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\cGUI.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\cLayout.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\cLabel.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\cPanel.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\cTextButton.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\cWindow.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cObject.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cTexture.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.cpp" />
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\GUIUtility.cpp" />
<ClCompile Include="TrooperEngine\InputEngine\cInput.cpp" />
<ClCompile Include="TrooperEngine\InputEngine\cJoystick.cpp" />
<ClCompile Include="TrooperEngine\InputEngine\cKey.cpp" />
<ClCompile Include="TrooperEngine\InputEngine\cKeyboard.cpp" />
<ClCompile Include="TrooperEngine\InputEngine\cMouse.cpp" />
<ClCompile Include="TrooperEngine\InputEngine\cTextInput.cpp" />
<ClCompile Include="TrooperEngine\MathEngine\cCollision.cpp" />
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector2.cpp" />
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector3.cpp" />
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector4.cpp" />
<ClCompile Include="TrooperEngine\MathEngine\Vector\Vector2.cpp" />
<ClCompile Include="TrooperEngine\MathEngine\Vector\Vector3.cpp" />
<ClCompile Include="TrooperEngine\MathEngine\Vector\Vector4.cpp" />
<ClCompile Include="TrooperEngine\TextTypeEngine\cFont.cpp" />
<ClCompile Include="TrooperEngine\TextTypeEngine\cText.cpp" />
<ClCompile Include="TrooperEngine\TextTypeEngine\cTextType.cpp" />
<ClCompile Include="TrooperEngine\TextTypeEngine\TextTypeHelpers\cFontHolder.cpp" />
<ClCompile Include="TrooperEngine\UtilityEngine\cString.cpp" />
<ClCompile Include="TrooperEngine\UtilityEngine\cUtility.cpp" />
<ClCompile Include="TrooperEngine\UtilityEngine\MSUNIX\msunix.cpp" />
<ClCompile Include="TrooperEngine\VideoEngine\cAnimatedSprite.cpp" />
<ClCompile Include="TrooperEngine\VideoEngine\cCamera.cpp" />
<ClCompile Include="TrooperEngine\VideoEngine\cImage.cpp" />
<ClCompile Include="TrooperEngine\VideoEngine\cRenderer.cpp" />
<ClCompile Include="TrooperEngine\VideoEngine\cSprite.cpp" />
<ClCompile Include="TrooperEngine\VideoEngine\cVideo.cpp" />
<ClCompile Include="TrooperEngine\TimingEngine\cTiming.cpp" />
<ClCompile Include="TrooperEngine\NetworkEngine\cNetwork.cpp" />
<ClCompile Include="TrooperEngine\TrooperEngineCore\cTrooperEngineCore.cpp" />
<ClCompile Include="TrooperEngine\MathEngine\cRandom.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
@@ -0,0 +1,363 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="dllExportFiles">
<UniqueIdentifier>{785f0a83-5f26-4f52-8607-42d79ef7e4a0}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine">
<UniqueIdentifier>{ce87c954-26c7-497c-a5c1-ca307fa85446}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\AudioEngine">
<UniqueIdentifier>{9447735f-408f-4a4c-896b-3cb056516952}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\InputEngine">
<UniqueIdentifier>{78ca6e8e-15cd-4c35-a4c7-f718c6f2e517}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\VideoEngine">
<UniqueIdentifier>{a48949b4-948d-4bdb-a48d-a2bb08c05f43}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\TimingEngine">
<UniqueIdentifier>{fb99b84e-7997-4ebd-b3ea-dd0240ce62f6}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\NetworkEngine">
<UniqueIdentifier>{98b7ca98-2ed4-4a41-84f2-abcb3fb384aa}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\TrooperEngineCore">
<UniqueIdentifier>{aef9e043-2065-4d89-acae-33d6f5f55958}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\MathEngine">
<UniqueIdentifier>{59e0e88b-7be3-4b1d-b3ac-6477daa761c8}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\TextTypeEngine">
<UniqueIdentifier>{4aa00373-6815-4cd3-a1c7-470f34bfa3d9}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\EventEngine">
<UniqueIdentifier>{74c65105-2ee7-4bb9-8d44-ca75c80e8b9e}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\MathEngine\iVector">
<UniqueIdentifier>{5a07ee53-1695-400c-86b3-c493e8e34417}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\MathEngine\Vector">
<UniqueIdentifier>{839730ba-b9b8-40bc-a0e0-bcb2b16b83f7}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\UtilityEngine">
<UniqueIdentifier>{2b72b3ea-71a4-4c02-988e-603172b3eda3}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\GUIEngine">
<UniqueIdentifier>{4a09c4e8-7d59-490d-8049-7a52f0aed3c8}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\GUIEngine\GUIHelpers">
<UniqueIdentifier>{6d0af3ff-4b2b-4b9c-85a2-c7db41550092}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\FXEngine">
<UniqueIdentifier>{db4ff7f3-2b38-4f9d-9a92-aed4cb51f0ac}</UniqueIdentifier>
</Filter>
<Filter Include="TrooperEngine\UtilityEngine\MSUNIX">
<UniqueIdentifier>{f6fc613b-8e1a-4df1-aee7-f37382d38981}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="dllExportFiles\dllExport.h">
<Filter>dllExportFiles</Filter>
</ClInclude>
<ClInclude Include="dllExportFiles\TrooperEngine.hpp">
<Filter>dllExportFiles</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\AudioEngine\cAudio.hpp">
<Filter>TrooperEngine\AudioEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\AudioEngine\cMusic.hpp">
<Filter>TrooperEngine\AudioEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\AudioEngine\cSound.hpp">
<Filter>TrooperEngine\AudioEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\InputEngine\cInput.hpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\InputEngine\cJoystick.hpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\InputEngine\cKey.hpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\InputEngine\cKeyboard.hpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\InputEngine\cMouse.hpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\VideoEngine\cAnimatedSprite.hpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\VideoEngine\cCamera.hpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\VideoEngine\cImage.hpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\VideoEngine\cSprite.hpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\VideoEngine\cVideo.hpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\TimingEngine\cTiming.hpp">
<Filter>TrooperEngine\TimingEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\NetworkEngine\cNetwork.hpp">
<Filter>TrooperEngine\NetworkEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\TrooperEngineCore\cTrooperEngineCore.hpp">
<Filter>TrooperEngine\TrooperEngineCore</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\MathEngine\cRandom.hpp">
<Filter>TrooperEngine\MathEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\TextTypeEngine\cFont.hpp">
<Filter>TrooperEngine\TextTypeEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\TextTypeEngine\cTextType.hpp">
<Filter>TrooperEngine\TextTypeEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\TextTypeEngine\cText.hpp">
<Filter>TrooperEngine\TextTypeEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\InputEngine\cTextInput.hpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClInclude>
<ClInclude Include="dllExportFiles\CompileSettings.h">
<Filter>dllExportFiles</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\MathEngine\cCollision.hpp">
<Filter>TrooperEngine\MathEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\cPanel.hpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\cButton.hpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cObject.hpp">
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cTexture.hpp">
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\cGUI.hpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\cBoxSizer.hpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector4.hpp">
<Filter>TrooperEngine\MathEngine\iVector</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector3.hpp">
<Filter>TrooperEngine\MathEngine\iVector</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\MathEngine\iVector\iVector2.hpp">
<Filter>TrooperEngine\MathEngine\iVector</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\MathEngine\Vector\Vector4.hpp">
<Filter>TrooperEngine\MathEngine\Vector</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\MathEngine\Vector\Vector3.hpp">
<Filter>TrooperEngine\MathEngine\Vector</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\MathEngine\Vector\Vector2.hpp">
<Filter>TrooperEngine\MathEngine\Vector</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\UtilityEngine\cUtility.hpp">
<Filter>TrooperEngine\UtilityEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\GUIUtility.hpp">
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\FXEngine\cGFX.hpp">
<Filter>TrooperEngine\FXEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\VideoEngine\cRenderer.hpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\TextTypeEngine\TextTypeHelpers\cFontHolder.hpp">
<Filter>TrooperEngine\TextTypeEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\UtilityEngine\cString.hpp">
<Filter>TrooperEngine\UtilityEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\Enums.hpp">
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\cLayout.hpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\cWindow.hpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\UtilityEngine\MSUNIX\msunix.hpp">
<Filter>TrooperEngine\UtilityEngine\MSUNIX</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\cLabel.hpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\cTextButton.hpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.hpp">
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\EventEngine\cEvent.hpp">
<Filter>TrooperEngine\EventEngine</Filter>
</ClInclude>
<ClInclude Include="TrooperEngine\EventEngine\cEventControl.hpp">
<Filter>TrooperEngine\EventEngine</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="TrooperEngine\AudioEngine\cAudio.cpp">
<Filter>TrooperEngine\AudioEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\AudioEngine\cMusic.cpp">
<Filter>TrooperEngine\AudioEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\AudioEngine\cSound.cpp">
<Filter>TrooperEngine\AudioEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\InputEngine\cInput.cpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\InputEngine\cJoystick.cpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\InputEngine\cKey.cpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\InputEngine\cKeyboard.cpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\InputEngine\cMouse.cpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\VideoEngine\cAnimatedSprite.cpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\VideoEngine\cCamera.cpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\VideoEngine\cImage.cpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\VideoEngine\cSprite.cpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\VideoEngine\cVideo.cpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\TimingEngine\cTiming.cpp">
<Filter>TrooperEngine\TimingEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\NetworkEngine\cNetwork.cpp">
<Filter>TrooperEngine\NetworkEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\TrooperEngineCore\cTrooperEngineCore.cpp">
<Filter>TrooperEngine\TrooperEngineCore</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\MathEngine\cRandom.cpp">
<Filter>TrooperEngine\MathEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\TextTypeEngine\cFont.cpp">
<Filter>TrooperEngine\TextTypeEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\TextTypeEngine\cTextType.cpp">
<Filter>TrooperEngine\TextTypeEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\TextTypeEngine\cText.cpp">
<Filter>TrooperEngine\TextTypeEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\InputEngine\cTextInput.cpp">
<Filter>TrooperEngine\InputEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\MathEngine\cCollision.cpp">
<Filter>TrooperEngine\MathEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\cButton.cpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cTexture.cpp">
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\cGUI.cpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cObject.cpp">
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector4.cpp">
<Filter>TrooperEngine\MathEngine\iVector</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\MathEngine\Vector\Vector4.cpp">
<Filter>TrooperEngine\MathEngine\Vector</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector3.cpp">
<Filter>TrooperEngine\MathEngine\iVector</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\MathEngine\iVector\iVector2.cpp">
<Filter>TrooperEngine\MathEngine\iVector</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\MathEngine\Vector\Vector2.cpp">
<Filter>TrooperEngine\MathEngine\Vector</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\MathEngine\Vector\Vector3.cpp">
<Filter>TrooperEngine\MathEngine\Vector</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\UtilityEngine\cUtility.cpp">
<Filter>TrooperEngine\UtilityEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\FXEngine\cGFX.cpp">
<Filter>TrooperEngine\FXEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\VideoEngine\cRenderer.cpp">
<Filter>TrooperEngine\VideoEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\TextTypeEngine\TextTypeHelpers\cFontHolder.cpp">
<Filter>TrooperEngine\TextTypeEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\GUIUtility.cpp">
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\UtilityEngine\cString.cpp">
<Filter>TrooperEngine\UtilityEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\cBoxSizer.cpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\UtilityEngine\MSUNIX\msunix.cpp">
<Filter>TrooperEngine\UtilityEngine\MSUNIX</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\cWindow.cpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\cLayout.cpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\cLabel.cpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\cTextButton.cpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\GUIHelpers\cXMLoader.cpp">
<Filter>TrooperEngine\GUIEngine\GUIHelpers</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\GUIEngine\cPanel.cpp">
<Filter>TrooperEngine\GUIEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\EventEngine\cEvent.cpp">
<Filter>TrooperEngine\EventEngine</Filter>
</ClCompile>
<ClCompile Include="TrooperEngine\EventEngine\cEventControl.cpp">
<Filter>TrooperEngine\EventEngine</Filter>
</ClCompile>
</ItemGroup>
</Project>
@@ -0,0 +1,7 @@
#ifndef _COMPILESETTINGS_H_
#define _COMPILESETTINGS_H_
#define _STATIC_LIB_ 1
#define _DEBUG_ 0
#endif/// END IFNDEF _COMPILESETTINGS_H_

Some files were not shown because too many files have changed in this diff Show More