Cleanup up a few font-related harcoded constants or duplicated code
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4366 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
2b152135da
commit
62ee51e383
@ -15,6 +15,8 @@ Okolaks font by Gluk, released under Open Font License
|
||||
|
||||
title_font, by Marianne Gagnon (Auria), released under CC-BY-SA 3+
|
||||
|
||||
screen*.png, by Marianne Gagnon (Auria), including elements from the public domain Tango icon set
|
||||
|
||||
====
|
||||
|
||||
Glass Skin by Auria, under CC-BY-SA 3+
|
||||
|
@ -88,7 +88,13 @@ namespace GUIEngine
|
||||
// otherwise check if the focus is the given widget
|
||||
return g_focus_for_player[playerID]->isSameIrrlichtWidgetAs(w);
|
||||
}
|
||||
|
||||
|
||||
int getFontHeight()
|
||||
{
|
||||
// FIXME: this needs to be reset when changing resolution
|
||||
static int fh = g_font->getDimension( L"X" ).Height;
|
||||
return fh;
|
||||
}
|
||||
// -----------------------------------------------------------------------------
|
||||
void clear()
|
||||
{
|
||||
|
@ -258,6 +258,9 @@ namespace GUIEngine
|
||||
inline AbstractStateManager* getStateManager() { return Private::g_state_manager; }
|
||||
inline Skin* getSkin() { return Private::g_skin; }
|
||||
|
||||
/** Returns the height of the font in pixels */
|
||||
int getFontHeight();
|
||||
|
||||
float getLatestDt();
|
||||
|
||||
/** Add a cutscene to the list of screens known by the gui engine */
|
||||
|
@ -60,7 +60,7 @@ void DynamicRibbonWidget::add()
|
||||
if (m_has_label)
|
||||
{
|
||||
// FIXME - won't work with multiline labels.
|
||||
m_label_height = GUIEngine::getFont()->getDimension( L"X" ).Height;
|
||||
m_label_height = GUIEngine::getFontHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ void IconButtonWidget::add()
|
||||
0 : atoi(m_properties[PROP_EXTEND_LABEL].c_str()) );
|
||||
widget_size = rect<s32>(x - label_extra_size/2, y + h, x + w + label_extra_size/2, y + h*2);
|
||||
|
||||
m_label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), widget_size, false, false /* word wrap */, m_parent);
|
||||
m_label = GUIEngine::getGUIEnv()->addStaticText(message.c_str(), widget_size, false, true /* word wrap */, m_parent);
|
||||
m_label->setTextAlignment(EGUIA_CENTER, EGUIA_UPPERLEFT);
|
||||
m_label->setTabStop(false);
|
||||
}
|
||||
|
@ -159,9 +159,8 @@ void RibbonWidget::add()
|
||||
{
|
||||
// how much space to keep for the label under the button
|
||||
const bool has_label = m_children[i].m_text.size() > 0;
|
||||
const int needed_space_under_button = has_label ? 30 : 10; // quite arbitrary for now
|
||||
const int needed_space_under_button = has_label ? GUIEngine::getFontHeight() : 10;
|
||||
|
||||
// For now, the image stretches to keep the aspect ratio of the widget (FIXME, doesn't work)
|
||||
float imageRatio = (float)m_children[i].w/(float)m_children[i].h;
|
||||
|
||||
// size of the image
|
||||
|
@ -35,7 +35,7 @@ using namespace irr::core;
|
||||
AddDeviceDialog::AddDeviceDialog() : ModalDialog(0.7f, 0.7f)
|
||||
{
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = font->getDimension(L"X").Height;
|
||||
const int textHeight = GUIEngine::getFontHeight();
|
||||
const int buttonHeight = textHeight + 10;
|
||||
|
||||
const int y_bottom = m_area.getHeight() - 2*(buttonHeight + 10) - 20;
|
||||
|
@ -47,7 +47,7 @@ EnterPlayerNameDialog::EnterPlayerNameDialog(const float w, const float h) :
|
||||
// ----
|
||||
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = font->getDimension(L"X").Height;
|
||||
const int textHeight = GUIEngine::getFontHeight();
|
||||
|
||||
const int textAreaYFrom = m_area.getHeight()/2 - textHeight/2;
|
||||
|
||||
|
@ -46,7 +46,7 @@ void PlayerInfoDialog::showRegularDialog()
|
||||
const int y4 = m_area.getHeight()*5/6;
|
||||
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = font->getDimension(L"X").Height;
|
||||
const int textHeight = GUIEngine::getFontHeight();
|
||||
const int buttonHeight = textHeight + 10;
|
||||
|
||||
{
|
||||
@ -122,7 +122,7 @@ void PlayerInfoDialog::showConfirmDialog()
|
||||
|
||||
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = font->getDimension(L"X").Height;
|
||||
const int textHeight = GUIEngine::getFontHeight();
|
||||
const int buttonHeight = textHeight + 10;
|
||||
|
||||
|
||||
|
@ -41,8 +41,8 @@ PressAKeyDialog::PressAKeyDialog(const float w, const float h) :
|
||||
widget->add();
|
||||
|
||||
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = font->getDimension(L"X").Height;
|
||||
//IGUIFont* font = GUIEngine::getFont();
|
||||
const int textHeight = GUIEngine::getFontHeight();
|
||||
|
||||
ButtonWidget* widget2 = new ButtonWidget();
|
||||
widget2->m_properties[PROP_ID] = "cancel";
|
||||
|
@ -45,7 +45,7 @@ RaceOverDialog::RaceOverDialog(const float percentWidth, const float percentHeig
|
||||
//const int h = m_area.getHeight();
|
||||
|
||||
IGUIFont* font = GUIEngine::getFont();
|
||||
const int text_height = font->getDimension(L"X").Height;
|
||||
const int text_height = GUIEngine::getFontHeight();
|
||||
|
||||
const int button_h = text_height + 6;
|
||||
const int margin_between_buttons = 12;
|
||||
|
@ -41,7 +41,7 @@ RacePausedDialog::RacePausedDialog(const float percentWidth, const float percent
|
||||
RaceManager::getWorld()->pause();
|
||||
|
||||
IGUIFont* font = GUIEngine::getTitleFont();
|
||||
const int text_height = font->getDimension(L"X").Height;
|
||||
const int text_height = GUIEngine::getFontHeight();
|
||||
|
||||
IGUIFont* titlefont = GUIEngine::getTitleFont();
|
||||
const int title_height = font->getDimension(L"X").Height;
|
||||
|
Loading…
Reference in New Issue
Block a user