Replaced multiple methods with one
parent
dd9439aed2
commit
52d9330114
|
@ -27,6 +27,8 @@
|
|||
|
||||
#include "common/system/system.h"
|
||||
|
||||
#include "graphics/engine/text.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <cstring>
|
||||
|
@ -84,7 +86,11 @@ bool CFontConfigFile::Init()
|
|||
return true;
|
||||
}
|
||||
|
||||
std::string CFontConfigFile::GetCommonFont()
|
||||
std::string CFontConfigFile::GetFont(Gfx::FontType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case Gfx::FONT_COMMON:
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -96,10 +102,8 @@ std::string CFontConfigFile::GetCommonFont()
|
|||
GetLogger()->Log(m_loaded ? LOG_INFO : LOG_TRACE, "Error on parsing config file: %s. Default font will be used instead.\n", e.what());
|
||||
return "/fonts/dvu_sans.ttf";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CFontConfigFile::GetCommonBoldFont()
|
||||
case Gfx::FONT_COMMON_BOLD:
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -111,10 +115,8 @@ std::string CFontConfigFile::GetCommonBoldFont()
|
|||
GetLogger()->Log(m_loaded ? LOG_INFO : LOG_TRACE, "Error on parsing config file: %s. Default font will be used instead.\n", e.what());
|
||||
return "/fonts/dvu_sans_bold.ttf";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CFontConfigFile::GetCommonItalicFont()
|
||||
case Gfx::FONT_COMMON_ITALIC:
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -126,10 +128,8 @@ std::string CFontConfigFile::GetCommonItalicFont()
|
|||
GetLogger()->Log(m_loaded ? LOG_INFO : LOG_TRACE, "Error on parsing config file: %s. Default font will be used instead.\n", e.what());
|
||||
return "/fonts/dvu_sans_italic.ttf";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CFontConfigFile::GetStudioFont()
|
||||
case Gfx::FONT_STUDIO:
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -141,10 +141,8 @@ std::string CFontConfigFile::GetStudioFont()
|
|||
GetLogger()->Log(m_loaded ? LOG_INFO : LOG_TRACE, "Error on parsing config file: %s. Default font will be used instead.\n", e.what());
|
||||
return "/fonts/dvu_sans_mono.ttf";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CFontConfigFile::GetStudioBoldFont()
|
||||
case Gfx::FONT_STUDIO_BOLD:
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -156,10 +154,8 @@ std::string CFontConfigFile::GetStudioBoldFont()
|
|||
GetLogger()->Log(m_loaded ? LOG_INFO : LOG_TRACE, "Error on parsing config file: %s. Default font will be used instead.\n", e.what());
|
||||
return "/fonts/dvu_sans_mono_bold.ttf";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string CFontConfigFile::GetSatComFont()
|
||||
case Gfx::FONT_SATCOM:
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -171,5 +167,11 @@ std::string CFontConfigFile::GetSatComFont()
|
|||
GetLogger()->Log(m_loaded ? LOG_INFO : LOG_TRACE, "Error on parsing config file: %s. Default font will be used instead.\n", e.what());
|
||||
return "/fonts/dvu_sans.ttf";
|
||||
}
|
||||
return "";
|
||||
}
|
||||
default:
|
||||
{
|
||||
GetLogger()->Debug("Incorrect font type: %i.\n", type);
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
#include "common/singleton.h"
|
||||
|
||||
#include "graphics/engine/text.h"
|
||||
|
||||
#include <boost/property_tree/ptree.hpp>
|
||||
|
||||
#include <string>
|
||||
|
@ -48,35 +50,10 @@ public:
|
|||
*/
|
||||
bool Init();
|
||||
|
||||
/** Reads common font from file
|
||||
/** Reads given font from file
|
||||
* \return return path to font file
|
||||
*/
|
||||
std::string GetCommonFont();
|
||||
|
||||
/** Reads common bold font from file
|
||||
* \return return path to font file
|
||||
*/
|
||||
std::string GetCommonBoldFont();
|
||||
|
||||
/** Reads common italic font from file
|
||||
* \return return path to font file
|
||||
*/
|
||||
std::string GetCommonItalicFont();
|
||||
|
||||
/** Reads studio font from file
|
||||
* \return return path to font file
|
||||
*/
|
||||
std::string GetStudioFont();
|
||||
|
||||
/** Reads studio bold font from file
|
||||
* \return returns path to font file
|
||||
*/
|
||||
std::string GetStudioBoldFont();
|
||||
|
||||
/** Reads satcom font from file
|
||||
* \return returns path to font file
|
||||
*/
|
||||
std::string GetSatComFont();
|
||||
std::string GetFont(Gfx::FontType type);
|
||||
|
||||
private:
|
||||
boost::property_tree::ptree m_propertyTree;
|
||||
|
|
|
@ -128,14 +128,14 @@ bool CText::Create()
|
|||
return false;
|
||||
}
|
||||
|
||||
m_fonts[FONT_COMMON] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetCommonFont());
|
||||
m_fonts[FONT_COMMON_BOLD] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetCommonBoldFont());
|
||||
m_fonts[FONT_COMMON_ITALIC] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetCommonItalicFont());
|
||||
m_fonts[FONT_COMMON] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetFont(FONT_COMMON));
|
||||
m_fonts[FONT_COMMON_BOLD] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetFont(FONT_COMMON_BOLD));
|
||||
m_fonts[FONT_COMMON_ITALIC] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetFont(FONT_COMMON_ITALIC));
|
||||
|
||||
m_fonts[FONT_SATCOM] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetSatComFont());
|
||||
m_fonts[FONT_SATCOM] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetFont(FONT_SATCOM));
|
||||
|
||||
m_fonts[FONT_STUDIO] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetStudioFont());
|
||||
m_fonts[FONT_STUDIO_BOLD] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetStudioBoldFont());
|
||||
m_fonts[FONT_STUDIO] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetFont(FONT_STUDIO));
|
||||
m_fonts[FONT_STUDIO_BOLD] = MakeUnique<MultisizeFont>(GetFontConfigFile().GetFont(FONT_STUDIO_BOLD));
|
||||
|
||||
for (auto it = m_fonts.begin(); it != m_fonts.end(); ++it)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue