Correct font scaling with resolution
parent
89a3f586a2
commit
d1942e1216
|
@ -903,14 +903,14 @@ Event CApplication::ProcessSystemEvent()
|
||||||
{
|
{
|
||||||
event.type = EVENT_QUIT;
|
event.type = EVENT_QUIT;
|
||||||
}
|
}
|
||||||
/*else if (m_private->currentEvent.type == SDL_VIDEORESIZE)
|
else if (m_private->currentEvent.type == SDL_VIDEORESIZE)
|
||||||
{
|
{
|
||||||
Gfx::GLDeviceConfig newConfig = m_deviceConfig;
|
Gfx::GLDeviceConfig newConfig = m_deviceConfig;
|
||||||
newConfig.size.x = m_private->currentEvent.resize.w;
|
newConfig.size.x = m_private->currentEvent.resize.w;
|
||||||
newConfig.size.y = m_private->currentEvent.resize.h;
|
newConfig.size.y = m_private->currentEvent.resize.h;
|
||||||
if (newConfig.size != m_deviceConfig.size)
|
if (newConfig.size != m_deviceConfig.size)
|
||||||
ChangeVideoConfig(newConfig);
|
ChangeVideoConfig(newConfig);
|
||||||
}*/
|
}
|
||||||
else if ( (m_private->currentEvent.type == SDL_KEYDOWN) ||
|
else if ( (m_private->currentEvent.type == SDL_KEYDOWN) ||
|
||||||
(m_private->currentEvent.type == SDL_KEYUP) )
|
(m_private->currentEvent.type == SDL_KEYUP) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -281,6 +281,8 @@ void CEngine::Destroy()
|
||||||
|
|
||||||
void CEngine::ResetAfterDeviceChanged()
|
void CEngine::ResetAfterDeviceChanged()
|
||||||
{
|
{
|
||||||
|
m_size = m_app->GetVideoConfig().size;;
|
||||||
|
|
||||||
m_text->FlushCache();
|
m_text->FlushCache();
|
||||||
|
|
||||||
// TODO reload textures, reset device state, etc.
|
// TODO reload textures, reset device state, etc.
|
||||||
|
|
|
@ -46,7 +46,7 @@ struct CachedFont
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
const Math::IntPoint REFERENCE_SIZE(800, 600);
|
||||||
|
|
||||||
|
|
||||||
CText::CText(CInstanceManager *iMan, CEngine* engine)
|
CText::CText(CInstanceManager *iMan, CEngine* engine)
|
||||||
|
@ -147,6 +147,10 @@ void CText::FlushCache()
|
||||||
f->cache.clear();
|
f->cache.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_lastFontType = FONT_COLOBOT;
|
||||||
|
m_lastFontSize = 0;
|
||||||
|
m_lastCachedFont = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CText::DrawText(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
|
void CText::DrawText(const std::string &text, std::map<unsigned int, FontMetaChar> &format,
|
||||||
|
@ -723,8 +727,8 @@ void CText::DrawCharAndAdjustPos(UTF8Char ch, FontType font, float size, Math::P
|
||||||
|
|
||||||
CachedFont* CText::GetOrOpenFont(FontType font, float size)
|
CachedFont* CText::GetOrOpenFont(FontType font, float size)
|
||||||
{
|
{
|
||||||
// TODO: sizing
|
Math::IntPoint windowSize = m_engine->GetWindowSize();
|
||||||
int pointSize = static_cast<int>(size);
|
int pointSize = static_cast<int>(size * (windowSize.Length() / REFERENCE_SIZE.Length()));
|
||||||
|
|
||||||
if (m_lastCachedFont != nullptr)
|
if (m_lastCachedFont != nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
// Math module namespace
|
// Math module namespace
|
||||||
namespace Math {
|
namespace Math {
|
||||||
|
@ -49,6 +50,11 @@ struct IntPoint
|
||||||
{
|
{
|
||||||
return !operator==(p);
|
return !operator==(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline float Length() const
|
||||||
|
{
|
||||||
|
return sqrtf(x*x + y*y);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue