Pre-resize fillparent

This commit is contained in:
2018-08-13 22:22:10 -04:00
parent 58fa6f0503
commit 353dc21750
95 changed files with 478 additions and 437 deletions
+2 -2
View File
@@ -123,8 +123,8 @@ void cPongStart::MainMenu()
void cPongStart::Start()
{
VideoEngine::cImage* p_image = new VideoEngine::cImage("img/", "Equipment.png", true, 0, 0, 0);
VideoEngine::cImage* p_court = new VideoEngine::cImage("img/", "Court.png");
VideoEngine::cImageFile* p_image = new VideoEngine::cImageFile("img/", "Equipment.png", true, 0, 0, 0);
VideoEngine::cImageFile* p_court = new VideoEngine::cImageFile("img/", "Court.png");
Equipment::cBall* ball = new Equipment::cBall(400, 400, 17, 65, 12, 12, &p_image);
Equipment::cPaddle* paddle = new Equipment::cPaddle(0, 0, 0, 0, 16, 77, &p_image);
@@ -17,7 +17,7 @@ cAudio::~cAudio()
CleanUp();
}
//Functions
/// Functions
/*static*/ cAudio& cAudio::Inst()
{
if (sp_inst == nullptr)
@@ -17,7 +17,7 @@ namespace AudioEngine {
~cAudio();
public:
//Functions
/// Functions
static cAudio& Inst();
static void Delete();
@@ -61,12 +61,12 @@ namespace AudioEngine {
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;
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;
static cAudio* sp_inst;/// = nullptr;
};/// END CLASS DEFINITION cAudio
}/// END NAMESPACE DEFINITION AudioEngine
#endif/// END IFNDEF _CAUDIO_HPP_
@@ -39,7 +39,7 @@ namespace AudioEngine {
/// Variables
Mix_Music* mp_music;
unsigned char m_volume;// = 255
unsigned char m_volume;/// = 255
};/// END CLASS DEFINITION cMusic
@@ -74,10 +74,10 @@ namespace AudioEngine {
private:
/// Variables
Mix_Chunk* mp_sound;// = nullptr
Mix_Chunk* mp_sound;/// = nullptr
cString m_dir;// = ""
cString m_fileName;// = ""
cString m_dir;/// = ""
cString m_fileName;/// = ""
unsigned char m_volume;// = 255
@@ -13,14 +13,14 @@ using UtilityEngine::cUtility;
/*static*/ cGFX* cGFX::sp_inst = nullptr;
//private:
/// private:
cGFX::cGFX()
{}
cGFX::~cGFX()
{}
//public:
/// public:
/// Functions
/*static*/ cGFX& cGFX::Inst()
{
@@ -43,7 +43,7 @@ namespace EXPORT_FROM_MYDLL FXEngine {
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
static cGFX* sp_inst;/// = nullptr
};/// END CLASS DEFINITION cGFX
}/// END NAMESPACE DEFINITION FXEngine
#endif/// END IFNDEF _CGFX_HPP_
@@ -2,7 +2,7 @@
using namespace GUIHelpers;
const RGBA& GUIHelpers::StringtoRGBA( const cString& colour )
const RGBA GUIHelpers::StringtoRGBA( const cString& colour )
{
RGBA rtn = DEFAULT;
cString check = colour.upper();
@@ -18,8 +18,6 @@ namespace GUIHelpers {
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 };
@@ -38,8 +36,9 @@ namespace GUIHelpers {
static const RGBA MAGENTA = { 255, 0, 255, 255 };
static const RGBA ROSE = { 255, 0, 128, 255 };
static const RGBA DEFAULT = WHITE;
const RGBA& StringtoRGBA(const cString& colour);
const RGBA StringtoRGBA(const cString& colour);
}/// END NAMESPACE DEFINITION GUIHelpers
#endif/// END IFNDEF _GUIUTILITY_HPP_
@@ -14,8 +14,6 @@ cTexture::~cTexture()
{}
/// Functions
//private
SDL_Texture* cTexture::GenerateTexture( const SDL_Rect& dimensions, TextTypeEngine::cText* text /*= nullptr*/ )
{
SDL_Rect t = text->getWH();
@@ -12,21 +12,15 @@ 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 };
}
: m_loadDef(false), m_debugXML(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;
@@ -83,14 +77,17 @@ void cXMLoader::GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* p
tmp->Resize();
}
const cString& cXMLoader::GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const
const cString cXMLoader::GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) const
{
cString rtn;
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
else {
if (str != nullptr)
rtn = str;
}
//rtn = str;
return rtn;
}
@@ -211,12 +208,12 @@ GUIEngine::cBoxSizer* cXMLoader::BoxSizerBuild(const tinyxml2::XMLElement& eleme
return rtn;
}
const cString& cXMLoader::getDir(const tinyxml2::XMLElement& element) const
const cString cXMLoader::getDir(const tinyxml2::XMLElement& element) const
{
return GetAttribute(element, "dir");
}
const cString& cXMLoader::getFileName(const tinyxml2::XMLElement& element) const
const cString cXMLoader::getFileName(const tinyxml2::XMLElement& element) const
{
return GetAttribute(element, "filename");
}
@@ -315,7 +312,7 @@ const GUIHelpers::eLayout cXMLoader::getLayout( const tinyxml2::XMLElement& elem
return rtn;
}
const GUIHelpers::Position& cXMLoader::getPosition( const tinyxml2::XMLElement& element ) const
const GUIHelpers::Position cXMLoader::getPosition( const tinyxml2::XMLElement& element ) const
{
GUIHelpers::Position rtn = { -1, -1 };
@@ -337,7 +334,7 @@ const GUIHelpers::Position& cXMLoader::getPosition( const tinyxml2::XMLElement&
return rtn;
}
const GUIHelpers::Size& cXMLoader::getSize( const tinyxml2::XMLElement& element ) const
const GUIHelpers::Size cXMLoader::getSize( const tinyxml2::XMLElement& element ) const
{
GUIHelpers::Size rtn = { -1, -1 };
@@ -359,7 +356,7 @@ const GUIHelpers::Size& cXMLoader::getSize( const tinyxml2::XMLElement& element
return rtn;
}
const GUIHelpers::Padding& cXMLoader::getPadding( const tinyxml2::XMLElement& element ) const
const GUIHelpers::Padding cXMLoader::getPadding( const tinyxml2::XMLElement& element ) const
{
GUIHelpers::Padding rtn = { -1, -1, -1, -1 };
@@ -385,12 +382,12 @@ const GUIHelpers::Padding& cXMLoader::getPadding( const tinyxml2::XMLElement& el
return rtn;
}
const cString& cXMLoader::getText( const tinyxml2::XMLElement& element ) const
const cString cXMLoader::getText( const tinyxml2::XMLElement& element ) const
{
return GetAttribute(element, "text");
}
const GUIHelpers::RGBA& cXMLoader::getColour( const tinyxml2::XMLElement& element ) const
const GUIHelpers::RGBA cXMLoader::getColour( const tinyxml2::XMLElement& element ) const
{
GUIHelpers::RGBA rtn = GUIHelpers::DEFAULT;
cString str = GetAttribute(element, "colour");
@@ -31,7 +31,7 @@ namespace GUIHelpers {
private:
void GetElement( tinyxml2::XMLElement& element, GUIEngine::cWindow* parent = nullptr ) const;
const cString& GetAttribute( const tinyxml2::XMLElement& element, const cString& attribute ) 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;
@@ -43,34 +43,34 @@ namespace GUIHelpers {
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 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::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 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;
bool m_loadDef;/// = false;
bool m_debugXML;/// = false;
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 };
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_
@@ -83,7 +83,7 @@ void cButton::Create( cWindow* parent, const signed int id, const GUIHelpers::eA
}
//private
/// private
void cButton::GenerateImage()
{
GenerateTexture();
@@ -42,7 +42,7 @@ namespace GUIEngine {
virtual void Press();
//Sets
/// Sets
/// Gets
virtual const GUIHelpers::eType getType() const;
@@ -53,11 +53,11 @@ namespace GUIEngine {
void GenerateTexture();
private:
VideoEngine::cImage* mp_texture;// = nullptr
VideoEngine::cImage* mp_texturePress;// = nullptr
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
VideoEngine::cImage** mpp_image;/// = nullptr
};/// END CLASS DEFINITION cButton
}/// END NAMESPACE DEFINITION GUIEngine
#endif/// END IFNDEF _CBUTTON_HPP_
@@ -81,14 +81,14 @@ namespace GUIEngine {
const bool IsInit() const;
private:
static cGUI* sp_inst;// = nullptr
static cGUI* sp_inst;/// = nullptr
unsigned long int m_debugLevel;// = 0
unsigned long int m_debugLevel;/// = 0
bool m_inited;// = false
bool m_inited;/// = false
/* default GUI font */
TextTypeEngine::cFont* mp_font;// = nullptr
TextTypeEngine::cFont* mp_font;/// = nullptr
/* default GUI text colour black*/
//GUIHelpers::RBGA m_textColour;// = { 0, 0, 0 }
@@ -53,7 +53,7 @@ void cLabel::GenerateTexture()
//this->setPosition()
}
//Sets
/// Sets
void cLabel::setFontColour(const GUIHelpers::RGBA& colour)
{
mp_text->setColour(colour);
@@ -33,7 +33,7 @@ namespace GUIEngine {
void GenerateTexture();
//Sets
/// Sets
void setFontColour( const GUIHelpers::RGBA& colour );
void setFontSize( const unsigned long int size );
void setText( const cString& text );
@@ -58,7 +58,7 @@ namespace GUIEngine {
private:
VideoEngine::cSprite m_sprite;
TextTypeEngine::cText* mp_text;// = nullptr
TextTypeEngine::cText* mp_text;/// = nullptr
};/// END CLASS DEFINITION cLabel
}/// END NAMESPACE DEFINITION GUIEngine
#endif/// END IFNDEF _CLABEL_HPP_
@@ -37,7 +37,6 @@ cLayout::cLayout(cWindow* parent, const signed int id, const GUIHelpers::eOrient
/// Set
/// Get
/*virtual*/ const GUIHelpers::eType cLayout::getType() const
{
return GUIHelpers::eType::CLAYOUT;
@@ -24,7 +24,7 @@ void cTextButton::Create(cWindow* parent, const signed int id, const cString& te
setText(text);
}
//Sets
/// Sets
void cTextButton::setText(const cString& text)
{
m_label.setText(text);
@@ -38,7 +38,7 @@ namespace GUIEngine {
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
/// Sets
void setText( const cString& text );
void setTextColour( const GUIHelpers::RGBA& colour );
void setTextSize( const unsigned long int size );
@@ -56,7 +56,7 @@ namespace GUIEngine {
void GenerateTexture();
private:
cLabel m_label;// = nullptr
cLabel m_label;/// = nullptr
};/// END CLASS DEFINITION cButton
}/// END NAMESPACE DEFINITION GUIEngine
#endif/// END IFNDEF _CBUTTON_HPP_
@@ -292,7 +292,7 @@ cWindow* cWindow::getParent()
return GUIHelpers::eType::CWINDOW;
}
///Protected
/// protected
/*virtual*/ void cWindow::Resize()
{
@@ -459,14 +459,14 @@ std::vector<cWindow*>& cWindow::getChildren()
return m_children;
}
//private
void cWindow::AddSize( int x, int y, GUIHelpers::Size& mySize ) const
/// private
void cWindow::AddSize( const int x, const int y, GUIHelpers::Size& mySize ) const
{
int& addFrom = x;
int& largestFrom = y;
int addFrom = x;
int largestFrom = y;
int& addTo = mySize.x;
int& largestTo = mySize.y;
int addTo = mySize.x;
int largestTo = mySize.y;
if (m_orientation == GUIHelpers::eOrientation::HORIZONTAL) {
addFrom = y;
@@ -105,22 +105,22 @@ namespace GUIEngine {
private:
void Rebuild( cWindow* const parent, const GUIHelpers::eLayout& layout );
void AddSize( int x, int y, GUIHelpers::Size& mySize ) const;
void AddSize( const int x, const 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;
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;/// = sNAME;
std::vector<cWindow*> m_children;
cWindow* mp_parent;// = nullptr;
cWindow* mp_parent;/// = nullptr;
};/// END CLASS DEFINITION cBoxSizer
}/// END NAMESPACE DEFINITION GUIEngine
#endif/// END IFNDEF _CBOXSIZER_HPP_
@@ -8,7 +8,7 @@ using UtilityEngine::cUtility;
/*static*/ cInput* cInput::sp_inst = nullptr;
//Private
/// private
cInput::cInput()
{}
@@ -17,7 +17,7 @@ cInput::~cInput()
CleanUp();
}
//Public
/// public
/*static*/ cInput& cInput::Inst()
{
if (sp_inst == nullptr)
@@ -31,7 +31,7 @@ cInput::~cInput()
sp_inst = nullptr;
}
//Functions
/// Functions
const bool cInput::Initialize() const
{
bool rtn = IsInit();
@@ -27,7 +27,7 @@ namespace InputEngine {
static cInput& Inst();
static void Delete();
//Functions
/// Functions
const bool Initialize() const;
const bool Setup();
@@ -30,7 +30,7 @@ namespace InputEngine {
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
/// Used when looking for keys that have been add to the check list
void JoystickCheck();
};/// END CLASS DEFINITION cJoystick
@@ -66,6 +66,7 @@ void cKeyboard::DeleteAllKeys()
}
/// Sets
/// Gets
const cString& cKeyboard::getLabel() const
{
return m_label;
@@ -32,9 +32,9 @@ namespace InputEngine {
cKeyboard( const cKeyboard& copy );
virtual ~cKeyboard();
///Funtions
/// Functions
//Used when looking for keys that have been add to the check list
/// 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 );
@@ -47,7 +47,7 @@ namespace InputEngine {
const cString& getLabel() const;
private:
cString m_label;// = ""
cString m_label;/// = ""
std::vector<InputEngine::cKey*> m_keys;
};/// END CLASS DEFINITION cKeyboard
@@ -61,7 +61,7 @@ const cString& cTextInput::getText() const
return m_text;
}
//Private
/// private
const char cTextInput::UnicodeValue( const SDL_Event& event )
{
event;
@@ -38,13 +38,13 @@ namespace InputEngine {
const char UnicodeValue( const SDL_Event& event );
private:
cString m_text;// = ""
bool m_caps;// = false
bool m_shift;// = false
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
/// 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_
@@ -14,6 +14,7 @@ cCollision::~cCollision()
{
}
/// Functions
/*static*/ const bool cCollision::BoundingBox( const SDL_Rect& a, const SDL_Rect& b )
{
if ((b.x + b.w) < a.x)
@@ -16,6 +16,7 @@ cRandom::cRandom()
cRandom::~cRandom()
{}
/// Functions
/*static*/ cRandom& cRandom::Inst()
{
if (sp_inst == nullptr)
@@ -26,7 +26,7 @@ namespace MathEngine {
const float Rand( const float max, const float min = 0.0f ) const;
private:
static cRandom* sp_inst;// = nullptr
static cRandom* sp_inst;/// = nullptr
};/// END CLASS DEFINITION cRandom
}/// END NAMESPACE DEFINITION MathEngine
#endif/// END IFNDEF _CRANDOM_HPP_
@@ -14,15 +14,15 @@ namespace TextTypeHelpers {
public:
cFontHolder( TTF_Font* font, const unsigned long int size );
~cFontHolder();
///Sets
/// Sets
/// Gets
TTF_Font* getFont() const;
const unsigned long int getSize() const;
private:
TTF_Font* mp_font;// = nullptr
unsigned long int m_size;// = 16
TTF_Font* mp_font;/// = nullptr
unsigned long int m_size;/// = 16
};/// END CLASS DEFINITION cFontHolder
}/// END NAMESPACE DEFINITION TextTypeHelpers
#endif/// END IFNDEF _CFONTHOLDER_HPP_
@@ -84,7 +84,23 @@ TTF_Font* cFont::getFont( const unsigned long int size )
return rtn;
}
//private:
bool cFont::operator == ( const cFont& rhs ) const
{
if ((this->m_dir == rhs.getDir()) && (this->m_fileName == rhs.getFileName()) && (this->getSize() == rhs.getSize()))
return true;
else
return false;
}
bool cFont::operator != ( const cFont& rhs ) const
{
if (*this == rhs)
return false;
else
return true;
}
/// private:
TTF_Font* cFont::LoadFont( const unsigned long int size )
{
TTF_Font* rtn = nullptr;
@@ -57,6 +57,10 @@ namespace TextTypeEngine {
/* Gets the TTF_Font. */
TTF_Font* getFont( const unsigned long int size );
/// operators
bool operator == ( const cFont& rhs ) const;
bool operator != ( const cFont& rhs ) const;
private:
TTF_Font* LoadFont( const unsigned long int size );
TextTypeHelpers::cFontHolder* getFontHolder( const unsigned long int size );
@@ -66,9 +70,9 @@ namespace TextTypeEngine {
std::vector<TextTypeHelpers::cFontHolder*> m_fonts;
//cFontHolder m_fonts;
//cFont::cFontHolder m_fonts;
TextTypeHelpers::cFontHolder** mpp_default;
cString m_dir;// = ""
cString m_fileName;// = ""
TextTypeHelpers::cFontHolder** mpp_default;/// = nullptr
cString m_dir;/// = ""
cString m_fileName;/// = ""
};/// END CLASS DEFINITION cFont
}/// END NAMESPACE DEFINITION TextTypeEngine
@@ -72,16 +72,20 @@ void cText::Red()
/// Sets
void cText::setSize(const unsigned long int size /*= 8*/)
{
if (m_size != size) {
m_size = size;
if ((mpp_font != nullptr) && ((*mpp_font) != nullptr))
(*mpp_font)->setSize(size);
}
}
void cText::setFont( TextTypeEngine::cFont** font )
{
if ((*mpp_font) != (*font)) {
mpp_font = font;
Text();
}
}
void cText::setText( const cString& text )
{
@@ -93,9 +97,11 @@ void cText::setText( const cString& text )
void cText::setColour( const SDL_Colour& colour )
{
if ((colour.a != m_colour.a) || (colour.b != m_colour.b) || (colour.g != m_colour.g) || (colour.r != m_colour.r)){
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*/ )
{
@@ -105,9 +111,11 @@ void cText::setColour( const unsigned long int red /*= 0*/, const unsigned long
void cText::setRender( const eRender& render /*= eRender::Solid*/ )
{
if (m_render != render) {
m_render = render;
Text();
}
}
/// Gets
const unsigned long int cText::getSize() const
@@ -146,7 +154,7 @@ const cText::eRender& cText::getRender() const
return m_render;
}
//Private
/// private
void cText::Text()
{
if((mpp_font != nullptr) && (*mpp_font != nullptr)) {
@@ -169,7 +177,7 @@ void cText::Text()
} 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_Texture* texture = cRenderer::Inst().NewTexture(8 * m_text.length(), 8, false, SDL_TEXTUREACCESS_TARGET);
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
//int t = SDL_SetTextureColorMod(texture, 0, 255, 0);
@@ -81,12 +81,12 @@ namespace TextTypeEngine {
void Text();
private:
TextTypeEngine::cFont** mpp_font;
cString m_text;// = ""
TextTypeEngine::cFont** mpp_font;/// = nullptr
cString m_text;/// = ""
unsigned long int m_size;// = 16
SDL_Colour m_colour;// = nullptr
eRender m_render;// = Solid
SDL_Colour m_colour;/// = nullptr
eRender m_render;/// = Solid
};/// END CLASS DEFINITION cText
}/// END NAMESPACE DEFINITION TextTypeEngine
#endif/// END IFNDEF _CTEXT_HPP_
@@ -8,7 +8,7 @@ using UtilityEngine::cUtility;
/*static*/ cTextType* cTextType::sp_inst = nullptr;
//private
/// private
cTextType::cTextType()
{
}
@@ -19,7 +19,7 @@ cTextType::~cTextType()
TTF_Quit();
}
//public:
/// public:
/// Functions
/*static*/ cTextType& cTextType::Inst()
{
@@ -34,7 +34,7 @@ namespace TextTypeEngine {
const bool IsInit() const;
private:
static cTextType* sp_inst;// = nullptr
static cTextType* sp_inst;/// = nullptr
};/// END CLASS DEFINITION cTextType
}/// END NAMESPACE DEFINITION TextTypeEngine
#endif/// END IFNDEF _CTEXTTYPE_HPP_
@@ -126,7 +126,7 @@ const float cTiming::getFrameTime() const
return m_frameTime;
}
///Private
/// private
/// Functions
const unsigned long int cTiming::TimeLeft()
{
@@ -52,17 +52,17 @@ namespace TimingEngine {
private:
/// Variables
unsigned long int m_nextTime;// = 0
unsigned long int m_nextTime;/// = 0
unsigned long int m_rate;// = (1000 / m_ftp)
unsigned long int m_rate;/// = (1000 / m_ftp)
unsigned long int m_ftp;// = 30
unsigned long int m_ftp;/// = 30
static cTiming* sp_inst;// = nullptr
static cTiming* sp_inst;/// = nullptr
unsigned long int m_start;// = 0
float m_lastTime;// = 0.0
float m_frameTime;// = 0.0
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_
@@ -62,7 +62,7 @@ namespace TrooperEngineCore {
private:
/// Variables
static cTrooperEngineCore* sp_inst;// = nullptr
static cTrooperEngineCore* sp_inst;/// = nullptr
};/// END CLASS DEFINITION cTrooperEngineCore
}/// END NAMESPACE DEFINITION TroopperENgineCore
#endif/// END IFNDEF _CTROOPERENGINECORE_HPP_
@@ -4,9 +4,9 @@
#include <stdlib.h> /* strtol */
#ifdef _MSC_VER
// disable _s warnings
/// disable _s warnings
# define _CRT_SECURE_NO_WARNINGS
// disable pragma warnings
/// disable pragma warnings
# pragma warning( disable : 4068 )
# pragma warning( disable : 4996 )
# include "MSUNIX/msunix.hpp"
@@ -86,7 +86,7 @@ size_t cString::size() const
return m_len;
}
// string format
/// string format
cString& cString::format(const char* format, ...)
{
char * buffer;
@@ -100,7 +100,7 @@ cString& cString::format(const char* format, ...)
return *this;
}
// trim leading and trailing spaces
/// trim leading and trailing spaces
cString& cString::trim()
{
const static char * whitespace = "\x20\x1b\t\r\n\v\b\f\a";
@@ -164,7 +164,7 @@ const char& cString::last_char() const
return mp_str[length() - 1];
}
// non-destructive split
/// non-destructive split
const std::vector<cString> cString::split(const char match) const
{
const char match_s[2] = { match, 0 };
@@ -185,14 +185,14 @@ const std::vector<cString> cString::split(const char* match, int max_split) cons
if (match_len >= __cString__MAX_LEN)
return rtn;
char* mi; // match index
char* pstr = mp_str; // string pointer
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
cslhs[lhsz] = '\0'; /// strncpy doesn't terminate it
rtn.emplace_back(strncpy(cslhs, pstr, lhsz)); /// calls cString copy ctor
pstr += lhsz;
free(cslhs);
}
@@ -22,17 +22,17 @@ namespace UtilityEngine {
class EXPORT_FROM_MYDLL cString
{
public:
cString(); // default constructor
cString(); /// default constructor
cString(const char* s);
cString(const cString& copy); // copy constructor
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
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
/// utility methods
bool have_value() const;
size_t length() const;
size_t size() const;
@@ -54,14 +54,14 @@ namespace UtilityEngine {
const bool IsInt() const;
const long int ToInt() const;
// operators
cString& operator = (const char* rhs); // assignment operator
cString& operator = (const cString& rhs); // assignment operator
/// 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
cString& operator += (const char* rhs); /// concatenation operator
cString& operator += (const cString& rhs); /// concatenation operator
bool operator == (const char* rhs) const; // comparisons
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;
@@ -70,16 +70,16 @@ namespace UtilityEngine {
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
/// 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
/// function overloads
UtilityEngine::cString operator + (const UtilityEngine::cString& lhs, const UtilityEngine::cString& rhs);
#endif/// END IFNDEF _CSTRING_HPP_
@@ -11,14 +11,14 @@ using UtilityEngine::cUtility;
/*static*/ cUtility* cUtility::sp_inst = nullptr;
//private:
/// private:
cUtility::cUtility()
{}
cUtility::~cUtility()
{}
//public:
/// public:
// cUtility& cUtility::operator=( const cUtility& copy )
// {
// if (this != &copy)
@@ -124,7 +124,7 @@ void cUtility::PrintVersion( const eTypeSDL typeSDL /*= eTypeSDL::ALL*/ ) const
}
}
///Private:
/// private:
/// Functions
void cUtility::VersionParser( const cString& runCompiled, const SDL_version& version, const cString& type ) const
{
@@ -2,7 +2,7 @@
#define _CUTILITY_HPP_
/*** ANSI C Header Files ***/
#include <stdio.h> //for __FUNCTION__
#include <stdio.h> /// for __FUNCTION__
#ifndef __FUNCTION__
# define __FUNCTION__ __func__
@@ -56,7 +56,7 @@ namespace UtilityEngine {
private:
/// Variables
static cUtility* sp_inst;// = nullptr
static cUtility* sp_inst;/// = nullptr
};/// END CLASS DEFINITION cUtility
}/// END NAMESPACE DEFINITION UtilityEngine
#endif/// END IFNDEF _CUTILITY_HPP_
@@ -56,14 +56,14 @@ namespace VideoEngine {
private:
/// Variables
unsigned long int m_xIncrement;// = 0
unsigned long int m_yIncrement;// = 0
unsigned long int m_xIncrement;/// = 0
unsigned long int m_yIncrement;/// = 0
unsigned long int m_fps;// = 16
unsigned long int m_fps;/// = 16
unsigned long int m_nextTime;// = 0
unsigned long int m_nextTime;/// = 0
unsigned long int m_RATE;// = 0
unsigned long int m_RATE;/// = 0
};/// END CLASS DEFINITION cAnimatedSprite
}/// END NAMESPACE DEFINITION VideoEngine
@@ -62,7 +62,7 @@ namespace VideoEngine {
/// Variables
SDL_Rect m_position;
SDL_Texture* mp_texture;// = nullptr
SDL_Texture* mp_texture;/// = nullptr
//std::vector<cSprite*> m_sprites;
//LinkList::cLList m_sprites;
@@ -187,7 +187,7 @@ const bool cImage::getIsSurface() const
return m_isSurface;
}
//protected:
/// protected:
void cImage::setImage( SDL_Surface* surface )
{
UnloadImage();
@@ -82,16 +82,16 @@ namespace VideoEngine {
private:
/// Variables
SDL_Texture* mp_texture;// = nullptr
SDL_Texture* mp_texture;/// = nullptr
SDL_Surface* mp_surface;// = nullptr
bool m_transparent;// = false
bool m_transparent;/// = false
unsigned char m_transRed;// = 0
unsigned char m_transBlue;// = 0
unsigned char m_transGreen;// = 255
unsigned char m_transRed;/// = 0
unsigned char m_transBlue;/// = 0
unsigned char m_transGreen;/// = 255
unsigned char m_transLevel;// = 255
unsigned char m_transLevel;/// = 255
bool m_isSurface;
};/// END CLASS DEFINITION cImage
@@ -45,8 +45,8 @@ namespace VideoEngine {
private:
/// Variables
cString m_dir;// = ""
cString m_fileName;// = ""
cString m_dir;/// = ""
cString m_fileName;/// = ""
};/// END CLASS DEFINITION cImageFile
}/// END NAMESPACE DEFINITION VideoEngine
#endif/// END IFNDEF _CIMAGEFILE_HPP_
@@ -10,7 +10,7 @@ using UtilityEngine::cUtility;
/*static*/ cRenderer* cRenderer::sp_inst = nullptr;
//private:
/// private:
cRenderer::cRenderer()
: mp_renderer(nullptr), mp_rendererSoftware(nullptr)
{
@@ -22,7 +22,7 @@ cRenderer::~cRenderer()
CleanUp();
}
//public:
/// public:
/// Functions
/*static*/ cRenderer& cRenderer::Inst()
{
@@ -27,18 +27,24 @@ cSprite::cSprite( VideoEngine::cImage** image, VideoEngine::cCamera** camera /*=
setEndImageArea(Uint16((*mpp_image)->getWidth()), Uint16((*mpp_image)->getHeight()));
}
//cSprite::cSprite( TextTypeEngine::cText** image, VideoEngine::cCamera** camera /*= nullptr*/ )
/*: mpp_camera(camera)
cSprite::cSprite( const cSprite& copy )
{
image;
//VideoEngine::cImage* im = VideoEngine::cImage(*image);
setPosition(0, 0);
setStartImageArea(0, 0);
setEndImageArea(Uint16((*mpp_image)->getWidth()), Uint16((*mpp_image)->getHeight()));
}*/
Copy(copy);
}
cSprite& cSprite::operator=( const cSprite& copy )
{
return Copy(copy);
}
cSprite::~cSprite()
{
mpp_image = nullptr;
mpp_camera = nullptr;
}
/// Functions
cSprite& cSprite::Copy( const cSprite & copy )
{
if (this != &copy)
{
@@ -63,17 +69,9 @@ cSprite& cSprite::operator=( const cSprite& copy )
*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();
@@ -196,7 +194,7 @@ void cSprite::setCamera( VideoEngine::cCamera** camera )
mpp_camera = camera;
}
///Get's
/// Gets
const signed long int cSprite::getPosX() const
{
return m_position.x;
@@ -28,10 +28,12 @@ namespace VideoEngine {
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( const cSprite& copy );
cSprite& operator=( const cSprite& copy );
~cSprite();
/// Functions
cSprite& Copy(const cSprite& copy);
/* Draws the sprite to the video buffer */
void Draw();
/* Draws the sprite to the camera */
@@ -109,8 +111,8 @@ namespace VideoEngine {
SDL_Rect m_imageArea; /// What part of the image to take
VideoEngine::cImage** mpp_image;// = nullptr
VideoEngine::cCamera** mpp_camera;// = nullptr
VideoEngine::cImage** mpp_image;/// = nullptr
VideoEngine::cCamera** mpp_camera;/// = nullptr
};/// END CLASS DEFINITION cSprite
}/// END NAMESPACE DEFINITION VideoEngine
#endif/// END IFNDEF _CSPRITE_HPP_
@@ -125,7 +125,7 @@ void cVideo::VideoSettings()
m_videoSettings = (m_videoSettings | SDL_WINDOW_FULLSCREEN);
}
///Set's
/// Sets
void cVideo::setWidth( const unsigned long int width /*= 640*/ )
{
m_width = width;
@@ -105,22 +105,22 @@ namespace VideoEngine {
private:
/// Variables
SDL_Window* mp_window;// = nullptr
//SDL_Renderer* mp_rend;// = nullptr
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
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
bool m_hardwareVideo;/// = false
bool m_fullscreen;/// = false
bool m_vsync;/// = false
unsigned long int m_videoSettings;// = SDL_RENDERER_SOFTWARE
unsigned long int m_videoSettings;/// = SDL_RENDERER_SOFTWARE
static cVideo* sp_inst;// = nullptr
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 */
@@ -7,7 +7,7 @@
void EventEngineTest()
{
// cString
/// cString
printf("\nTesting cString -----\n\n");
UTest u("cString");
@@ -3,4 +3,4 @@
void EventEngineTest();
#endif //__EVENTENGINETEST__
#endif ///__EVENTENGINETEST__
@@ -316,8 +316,6 @@ void GUIXMLBoxSizerTest()
u.report();
GUIEngine::cGUI::Inst().Delete();
}
void LoadFile( const cString& filename, const bool show /*= false*/ )
@@ -34,4 +34,4 @@ void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const S
void cWindowTest( const cString& msg, UTest& u, GUIEngine::cWindow* win, const GUIHelpers::Position& pos,
const GUIHelpers::Size& size, const GUIHelpers::Padding& pad, const GUIHelpers::Position& center );
#endif // __GUIXMLTEST__
#endif /// __GUIXMLTEST__
@@ -150,6 +150,7 @@
<ClCompile Include="main.cpp" />
<ClCompile Include="UTest\UTest.cpp" />
<ClCompile Include="UtilityEngineTest\StringTest.cpp" />
<ClCompile Include="UtilityEngineTest\UtilityEngineTest.cpp" />
<ClCompile Include="VideoEngineTest\ImageFileTest.cpp" />
<ClCompile Include="VideoEngineTest\RendererTest.cpp" />
<ClCompile Include="VideoEngineTest\VideoEngineTest.cpp" />
@@ -160,6 +161,7 @@
<ClInclude Include="GUIEngineTest\GUIXMLTest.hpp" />
<ClInclude Include="UTest\UTest.hpp" />
<ClInclude Include="UtilityEngineTest\StringTest.hpp" />
<ClInclude Include="UtilityEngineTest\UtilityEngineTest.hpp" />
<ClInclude Include="VideoEngineTest\ImageFileTest.hpp" />
<ClInclude Include="VideoEngineTest\RendererTest.hpp" />
<ClInclude Include="VideoEngineTest\VideoEngineTest.hpp" />
@@ -45,6 +45,9 @@
<ClInclude Include="VideoEngineTest\VideoEngineTest.hpp">
<Filter>VideoEngineTest</Filter>
</ClInclude>
<ClInclude Include="UtilityEngineTest\UtilityEngineTest.hpp">
<Filter>UtitlityEngineTest</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="UTest\UTest.cpp">
@@ -72,6 +75,9 @@
<ClCompile Include="VideoEngineTest\VideoEngineTest.cpp">
<Filter>VideoEngineTest</Filter>
</ClCompile>
<ClCompile Include="UtilityEngineTest\UtilityEngineTest.cpp">
<Filter>UtitlityEngineTest</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Xml Include="xml\GUI.xml">
@@ -9,7 +9,7 @@ using UtilityEngine::cString;
void StringTest()
{
// cString
/// cString
printf("\nTesting cString -----\n\n");
UTest u("cString");
@@ -3,4 +3,4 @@
void StringTest();
#endif // __STRINGTEST__
#endif /// __STRINGTEST__
@@ -0,0 +1,8 @@
#include "UtilityEngineTest.hpp"
#include "StringTest.hpp"
void UtilityEngineTest()
{
StringTest();
}
@@ -0,0 +1,6 @@
#ifndef __UTILITYENGINETEST__
#define __UTILITYENGINETEST__
void UtilityEngineTest();
#endif /// __UTILITYENGINETEST__
@@ -11,7 +11,7 @@ using VideoEngine::cSprite;
void ImageFileTest()
{
// cImageFile
/// cImageFile
printf("\nTesting cImageFile -----\n\n");
UTest u("cImageFile");
@@ -3,4 +3,4 @@
void ImageFileTest();
#endif // __IMAGEFILETEST__
#endif /// __IMAGEFILETEST__
@@ -23,7 +23,7 @@ void RendererTest()
//u.test("Screen Shot", RendererTextureToSurface());
///u.test("Screen Shot", RendererTextureToSurface());
u.report();
@@ -9,4 +9,4 @@ const bool RendererAreaEqualNotEqual();
const bool RendererTextureToSurface();
#endif // __RENDERERTEST__
#endif /// __RENDERERTEST__
@@ -3,4 +3,4 @@
void VideoEngineTest();
#endif // __VIDEOENGINETEST__
#endif /// __VIDEOENGINETEST__
@@ -9,7 +9,7 @@ using VideoEngine::cVideo;
void VideoTest()
{
// cVideo
/// cVideo
printf("\nTesting cVideo -----\n\n");
UTest u("cVideo");
@@ -22,7 +22,7 @@ void VideoTest()
u.test("Video Setup. Setup()", video.Setup());
// CaptionTest
/// CaptionTest
u.test("setCaption() and getCaption()", CaptionTest());
u.report();
@@ -5,4 +5,4 @@ void VideoTest();
const bool CaptionTest();
#endif // __VIDEOTEST__
#endif /// __VIDEOTEST__
+4 -4
View File
@@ -26,7 +26,7 @@ see license.txt for details
#include "VideoEngineTest/VideoEngineTest.hpp"
/*** Utility Engine Test ***/
#include "UtilityEngineTest/StringTest.hpp"
#include "UtilityEngineTest/UtilityEngineTest.hpp"
/*** GUI Engine Test ***/
#include "GUIEngineTest/GUIXMLTest.hpp"
@@ -47,12 +47,12 @@ int main(int argc, char *argv[])
VideoEngineTest();
//UtilityEngineTest();
UtilityEngineTest();
//StringTest();
//GUIXMLTest();
GUIXMLTest();
//ImageTest();
@@ -4,5 +4,6 @@
<Layout>
<Boxsizer />
<Label text="Box Sizer" />
<Boxsizer />
</Layout>
</Panel>
@@ -3,5 +3,6 @@
<debug/>
<Layout>
<Label text="Hello world" />
<Include dir ="xml/" filename="include.xml"/>
</Layout>
</Panel>
+2 -7
View File
@@ -1,8 +1,3 @@
<?xml version="1.0"?>
<Layout layout="wrap_content">
<Label
text="Hello World2"
padding=""/>
<Label
text="Richard Allen2"/>
</Layout>
<Boxsizer />
<Label text="Box Sizer" />