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,124 @@
#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 );
void RemoveChild( cWindow* obj );
///Sets
static void PositionDefault( const GUIHelpers::Position& pos );
static void SizeDefault( const GUIHelpers::Size& size );
static void PaddingDefault( const GUIHelpers::Padding& pad );
static void AlignDefault( const GUIHelpers::eAlign& align );
static void LayoutDefault( const GUIHelpers::eLayout& layout );
static void OrientationDefault( const GUIHelpers::eOrientation& orientation );
void setOrientation( const GUIHelpers::eOrientation& orientation = sORIENTATION );
void setAlign( const GUIHelpers::eAlign& align = sALIGN );
void setLayout( const GUIHelpers::eLayout& layout = sLAYOUT );
void setPosition( const GUIHelpers::Position& pos = sPOSITION );
void setSize( const GUIHelpers::Size& size = sSIZE );
void setPadding( const GUIHelpers::Padding& padding = sPADDING );
void setContentSize( const GUIHelpers::Size& content );
void setName( const cString& name = sNAME );
void setParent( cWindow* parent );
///Gets
const GUIHelpers::Position getCenter( const bool pad = true ) const;
const GUIHelpers::eOrientation& getOrientation() const;
const GUIHelpers::eAlign& getAlign() const;
const GUIHelpers::eLayout& getLayout() const;
const GUIHelpers::Position getPosition( const bool pad = true ) const;
const GUIHelpers::Size getSize( const bool pad = true ) const;
const GUIHelpers::Padding& getPadding() const;
const GUIHelpers::Size& getContentSize() const;
const cString& getName() const;
cWindow* getParent();
virtual const GUIHelpers::eType getType() const;
virtual void Resize();
virtual void RebuildLayout( const GUIHelpers::eLayout& layout );
virtual void RePos();
virtual void RebuildPos();
virtual const GUIHelpers::RGBA getDebugColour() const;
/*protected:*/
std::vector<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,170 @@
#include "cButton.hpp"
/*** Custom Header Files ***/
#include "GUIHelpers/Enums.hpp"
#include "../VideoEngine/cRenderer.hpp"
#include "../FXEngine/cGFX.hpp"
using GUIEngine::cButton;
using MathEngine::iVector2;
using MathEngine::iVector4;
/*static*/ const cString cButton::sNAME = "button";
cButton::cButton()
{}
cButton::cButton( cWindow* parent, const signed int id, const GUIHelpers::eAlign& align /*= sALIGN*/, const GUIHelpers::eLayout& layout /*= sLAYOUT*/,
const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding/* = sPADDING*/,
const cString& name /*= sNAME*/, VideoEngine::cImage** image /*= nullptr*/ )
: cWindow(parent, id, align, layout, pos, size, padding, name)
{
//Create(parent, id, align, layout, pos, size, padding, name, image);
mp_texture = nullptr;
mp_texturePress = nullptr;
mpp_image = image;
GenerateImage();
}
/*virtual*/ cButton::~cButton()
{
delete mp_texture;
mp_texture = nullptr;
delete mp_texturePress;
mp_texturePress = nullptr;
}
///Functions
void cButton::Create( cWindow* parent, const signed int id, const GUIHelpers::eAlign& align /*= sALIGN*/, const GUIHelpers::eLayout& layout /*= sLAYOUT*/,
const GUIHelpers::Position& pos /*= sPOSITION*/, const GUIHelpers::Size& size /*= sSIZE*/, const GUIHelpers::Padding& padding /*= sPADDING*/,
const cString& name /*= sNAME*/, VideoEngine::cImage** image /*= nullptr*/ )
{
//cWindow(parent, id, align, layout, pos, size, padding, name);
mp_texture = nullptr;
mp_texturePress = nullptr;
mpp_image = image;
GenerateImage();
}
/*virtual*/ void cButton::Press()
{
mp_texture->SaveImage("hello.bmp");
}
// void cButton::setLabel( const cString& label )
// {
// if (label.size() > 0) {
// if (mp_label == nullptr)
// mp_label = new TextTypeEngine::cText(label);
// else
// mp_label->setText(label);
// }
// }
///Gets
// const cString cButton::getLabel() const
// {
// cString rtn = "";
// if (mp_label != nullptr)
// rtn = mp_label->getText();
// return rtn;
// }
/*virtual*/ const GUIHelpers::eType cButton::getType() const
{
return GUIHelpers::eType::CBUTTON;
}
//private
void cButton::GenerateImage()
{
GenerateTexture();
//GenerateTexture( mp_texturePress );
this->setImage((VideoEngine::cImage**)(&mp_texture));
this->setImageArea(mp_texture->getWH());
}
void cButton::GenerateTexture()
{
// SDL_Rect t = { 0, 0, 0, 0 };
// if (mp_label != nullptr)
// t = mp_label->getWH();
// SDL_Rect centerText = { 0, 0, 0, 0 };
// SDL_Rect centerButton = { 0, 0, 0, 0 };
// SDL_Rect dim = this->getImageArea();
//
// GUIHelpers::Padding TXTPADDING = PADDING;
// ///Find the min padding around the text.
// if (dim.w < (t.w + TXTPADDING.x + TXTPADDING.w) )
// dim.w += (t.w + TXTPADDING.x + TXTPADDING.w);
//
// if (dim.h < (t.h + TXTPADDING.y + TXTPADDING.z) )
// dim.h += (t.h + TXTPADDING.y + TXTPADDING.z);
//
// ///Find the center of the button
// centerButton.x = dim.w / 2;
// centerButton.y = dim.h / 2;
//
// ///Find the center of the text
// centerText.x = t.w / 2;
// centerText.y = t.h / 2;
//
// if (centerText.x < centerButton.x)
// t.x = centerButton.x - centerText.x;
//
// if (centerText.y < centerButton.y)
// t.y = centerButton.y - centerText.y;
//
// SDL_Texture* temptext = VideoEngine::cRenderer::Inst().NewTexture(dim.w, dim.h, SDL_TEXTUREACCESS_TARGET );
//
// GUIHelpers::RBGA colour = { 100, 100, 100, 255 };
//
// FXEngine::cGFX::Inst().RoundedRectangle(dim, 4, colour, temptext);
//
//
// if (mp_label != nullptr)
// VideoEngine::cRenderer::Inst().RenderToTexture(mp_label->getImage(), nullptr, temptext, &t);
//cRenderer::Inst().Render(temptext, nullptr, nullptr);
//cRenderer::Inst().RenderToTexture(temptext, nullptr, text->getImage(), nullptr);
/*SDL_Surface* tempsurface = SDL_CreateRGBSurface(cVideo::Inst().getVideoSettings(), dimensions.w, dimensions.h, cVideo::Inst().getColour(),
0, 0, 0, 0);
SDL_FillRect(tempsurface, nullptr, SDL_MapRGB(tempsurface->format, 0, 255, 0));
/*if (roundedBoxRGBA(tempsurface, dimensions.x, dimensions.y, dimensions.w, dimensions.h, 10, 255, 255, 0, 255) != 0)
cerr << "Unable to generate GUI Texture." << endl << SDL_GetError() << endl;*/
/*if (text != nullptr) {
SDL_Rect srcrect, dstrect = dimensions;
cVideo::Inst().Render(text->getImage(), &srcrect, temptext, &dstrect);
}
this->setImage(temptext);
this->setTransparent();*/
// delete mp_texture;
// mp_texture = nullptr;
//
// mp_texture = new VideoEngine::cImage(temptext);
//
// GUIHelpers::Size size = { 0, 0 };
// mp_texture->getWH((unsigned long&)size.x, (unsigned long&)size.y);
// cWindow::setSize(size);
// image->setImage(temptext);
//image->setImage(temptext);
}
@@ -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_