Add MathEngineTest and Commects and clean ups
This commit is contained in:
@@ -21,6 +21,7 @@ namespace TextTypeHelpers {
|
||||
const unsigned long int getSize() const;
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
TTF_Font* mp_font;/// = nullptr
|
||||
unsigned long int m_size;/// = 16
|
||||
};/// END CLASS DEFINITION cFontHolder
|
||||
|
||||
@@ -7,7 +7,7 @@ using TextTypeEngine::cFont;
|
||||
using TextTypeHelpers::cFontHolder;
|
||||
using UtilityEngine::cUtility;
|
||||
|
||||
cFont::cFont( const cString& filename /*= ""*/, const cString& dir /*= ""*/, const unsigned long int size /*= 16*/ )
|
||||
cFont::cFont( const cString& filename /*= ""*/, const cString& dir /*= ""*/, const unsigned long int size /*= 8*/ )
|
||||
: m_dir(dir), m_fileName(filename), mpp_default(nullptr)
|
||||
{
|
||||
setSize(size);
|
||||
@@ -42,7 +42,7 @@ void cFont::setFileNameandDir( const cString& filename, const cString& dir /*= "
|
||||
setFileName(filename);
|
||||
}
|
||||
|
||||
void cFont::setSize( const unsigned long int size /*= 16*/ )
|
||||
void cFont::setSize( const unsigned long int size /*= 8*/ )
|
||||
{
|
||||
while ((mpp_default == nullptr) || ((*mpp_default) == nullptr)) {
|
||||
getFont(size);
|
||||
|
||||
@@ -28,12 +28,11 @@ namespace TextTypeEngine {
|
||||
class EXPORT_FROM_MYDLL cFont
|
||||
{
|
||||
public:
|
||||
cFont( const cString& filename = "", const cString& dir = "", const unsigned long int size = 16 );
|
||||
cFont( const cString& filename = "", const cString& dir = "", const unsigned long int size = 8 );
|
||||
cFont( const cFont& copy );
|
||||
~cFont();
|
||||
|
||||
/// Functions
|
||||
|
||||
/// Functions
|
||||
|
||||
/// Sets
|
||||
/* Sets the Directory of the TTF file */
|
||||
@@ -43,7 +42,7 @@ namespace TextTypeEngine {
|
||||
/* 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 );
|
||||
void setSize( const unsigned long int size = 8 );
|
||||
|
||||
/// Gets
|
||||
/* Gets the Directory of the TTF file */
|
||||
@@ -67,13 +66,13 @@ namespace TextTypeEngine {
|
||||
void UnloadFont();
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
std::vector<TextTypeHelpers::cFontHolder*> m_fonts;
|
||||
//cFontHolder m_fonts;
|
||||
//cFont::cFontHolder m_fonts;
|
||||
TextTypeHelpers::cFontHolder** mpp_default;/// = nullptr
|
||||
cString m_dir;/// = ""
|
||||
cString m_fileName;/// = ""
|
||||
|
||||
};/// END CLASS DEFINITION cFont
|
||||
}/// END NAMESPACE DEFINITION TextTypeEngine
|
||||
#endif/// END IFNDEF _CFONT_HPP_
|
||||
@@ -76,6 +76,7 @@ void cText::setSize( const unsigned long int size /*= 8*/ )
|
||||
m_size = size;
|
||||
if ((mpp_font != nullptr) && ((*mpp_font) != nullptr))
|
||||
(*mpp_font)->setSize(size);
|
||||
Text();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -157,6 +158,8 @@ const cText::eRender& cText::getRender() const
|
||||
/// private
|
||||
void cText::Text()
|
||||
{
|
||||
/// if we have a font use SDL2_ttf to render the text.
|
||||
/// else use SDL2_gfx to render text and use ZoomIn if it's size is larger then 8.
|
||||
if((mpp_font != nullptr) && (*mpp_font != nullptr)) {
|
||||
SDL_Surface* sur = nullptr;
|
||||
switch (m_render)
|
||||
@@ -176,39 +179,19 @@ void cText::Text()
|
||||
setImage(sur);
|
||||
} else {
|
||||
SDL_Rect pos = { 0, 0, 0, 0 };
|
||||
//m_size == 25;
|
||||
SDL_Texture* texture = cRenderer::Inst().NewTexture(8 * m_text.length(), 8, false, SDL_TEXTUREACCESS_TARGET);
|
||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||
SDL_Texture* texture = cGFX::Inst().StringTexture(m_text, pos, m_colour);
|
||||
|
||||
//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);
|
||||
if (m_size > 8) {
|
||||
SDL_Texture* newTexture = cRenderer::Inst().NewTexture(((m_size / 4) * m_text.length()), m_size);
|
||||
|
||||
double x = ((m_size / 4 ) * m_text.length()) / 8;
|
||||
double y = m_size / 8;
|
||||
setImage(cGFX::Inst().ZoomIn(texture, x, y, SMOOTHING_ON));
|
||||
SDL_DestroyTexture(texture);
|
||||
}
|
||||
else
|
||||
setImage(texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,10 +81,11 @@ namespace TextTypeEngine {
|
||||
void Text();
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
TextTypeEngine::cFont** mpp_font;/// = nullptr
|
||||
cString m_text;/// = ""
|
||||
|
||||
unsigned long int m_size;// = 16
|
||||
unsigned long int m_size;/// = 16
|
||||
SDL_Colour m_colour;/// = nullptr
|
||||
eRender m_render;/// = Solid
|
||||
};/// END CLASS DEFINITION cText
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace TextTypeEngine {
|
||||
const bool IsInit() const;
|
||||
|
||||
private:
|
||||
/// Variables
|
||||
static cTextType* sp_inst;/// = nullptr
|
||||
};/// END CLASS DEFINITION cTextType
|
||||
}/// END NAMESPACE DEFINITION TextTypeEngine
|
||||
|
||||
Reference in New Issue
Block a user