Add race gui resizing
This commit is contained in:
parent
83a49068e4
commit
0a7f9cd314
@ -2353,6 +2353,7 @@ void IrrDriver::resizeWindow()
|
||||
sbr->onLoadWorld();
|
||||
}
|
||||
STKTextBillboard::updateAllTextBillboards();
|
||||
World::getWorld()->getRaceGUI()->recreateGUI();
|
||||
}
|
||||
|
||||
#ifdef ENABLE_RECORDER
|
||||
|
@ -148,7 +148,7 @@ GUIEngine::EventPropagation MultitouchSettingsDialog::processEvent(
|
||||
|
||||
if (World::getWorld() && World::getWorld()->getRaceGUI())
|
||||
{
|
||||
World::getWorld()->getRaceGUI()->recreateMultitouchGUI();
|
||||
World::getWorld()->getRaceGUI()->recreateGUI();
|
||||
}
|
||||
|
||||
user_config->saveConfig();
|
||||
|
@ -149,7 +149,7 @@ RacePausedDialog::~RacePausedDialog()
|
||||
|
||||
if (World::getWorld() && World::getWorld()->getRaceGUI())
|
||||
{
|
||||
World::getWorld()->getRaceGUI()->recreateMultitouchGUI();
|
||||
World::getWorld()->getRaceGUI()->recreateGUI();
|
||||
}
|
||||
|
||||
user_config->saveConfig();
|
||||
|
@ -71,29 +71,7 @@ RaceGUI::RaceGUI()
|
||||
if (UserConfigParams::m_artist_debug_mode && UserConfigParams::m_hide_gui)
|
||||
m_enabled = false;
|
||||
|
||||
// Determine maximum length of the rank/lap text, in order to
|
||||
// align those texts properly on the right side of the viewport.
|
||||
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
|
||||
core::dimension2du area = font->getDimension(L"99:99.999");
|
||||
m_timer_width = area.Width;
|
||||
m_font_height = area.Height;
|
||||
|
||||
area = font->getDimension(L"99.999");
|
||||
m_small_precise_timer_width = area.Width;
|
||||
|
||||
area = font->getDimension(L"99:99.999");
|
||||
m_big_precise_timer_width = area.Width;
|
||||
|
||||
area = font->getDimension(L"-");
|
||||
m_negative_timer_additional_width = area.Width;
|
||||
|
||||
if (RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER ||
|
||||
RaceManager::get()->isBattleMode() ||
|
||||
RaceManager::get()->getNumLaps() > 9)
|
||||
m_lap_width = font->getDimension(L"99/99").Width;
|
||||
else
|
||||
m_lap_width = font->getDimension(L"9/9").Width;
|
||||
|
||||
initSize();
|
||||
bool multitouch_enabled = (UserConfigParams::m_multitouch_active == 1 &&
|
||||
irr_driver->getDevice()->supportsTouchDevice()) ||
|
||||
UserConfigParams::m_multitouch_active > 1;
|
||||
@ -125,6 +103,35 @@ RaceGUI::RaceGUI()
|
||||
m_champion = irr_driver->getTexture(FileManager::GUI_ICON, "cup_gold.png");
|
||||
} // RaceGUI
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Called when loading the race gui or screen resized. */
|
||||
void RaceGUI::initSize()
|
||||
{
|
||||
RaceGUIBase::initSize();
|
||||
// Determine maximum length of the rank/lap text, in order to
|
||||
// align those texts properly on the right side of the viewport.
|
||||
gui::ScalableFont* font = GUIEngine::getHighresDigitFont();
|
||||
core::dimension2du area = font->getDimension(L"99:99.999");
|
||||
m_timer_width = area.Width;
|
||||
m_font_height = area.Height;
|
||||
|
||||
area = font->getDimension(L"99.999");
|
||||
m_small_precise_timer_width = area.Width;
|
||||
|
||||
area = font->getDimension(L"99:99.999");
|
||||
m_big_precise_timer_width = area.Width;
|
||||
|
||||
area = font->getDimension(L"-");
|
||||
m_negative_timer_additional_width = area.Width;
|
||||
|
||||
if (RaceManager::get()->getMinorMode()==RaceManager::MINOR_MODE_FOLLOW_LEADER ||
|
||||
RaceManager::get()->isBattleMode() ||
|
||||
RaceManager::get()->getNumLaps() > 9)
|
||||
m_lap_width = font->getDimension(L"99/99").Width;
|
||||
else
|
||||
m_lap_width = font->getDimension(L"9/9").Width;
|
||||
} // initSize
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RaceGUI::~RaceGUI()
|
||||
{
|
||||
|
@ -155,6 +155,7 @@ public:
|
||||
/** Returns the size of the texture on which to render the minimap to. */
|
||||
virtual const core::dimension2du getMiniMapSize() const
|
||||
{ return core::dimension2du(m_map_width, m_map_height); }
|
||||
virtual void initSize();
|
||||
virtual void calculateMinimapSize();
|
||||
}; // RaceGUI
|
||||
|
||||
|
@ -63,9 +63,8 @@ namespace irr
|
||||
|
||||
RaceGUIBase::RaceGUIBase()
|
||||
{
|
||||
initSize();
|
||||
m_ignore_unimportant_messages = false;
|
||||
m_max_font_height = GUIEngine::getFontHeight() + 10;
|
||||
m_small_font_max_height = GUIEngine::getSmallFontHeight() + 5;
|
||||
//I18N: as in "ready, set, go", shown at the beginning of the race
|
||||
m_string_ready = _("Ready!");
|
||||
//I18N: as in "ready, set, go", shown at the beginning of the race
|
||||
@ -126,6 +125,14 @@ RaceGUIBase::RaceGUIBase()
|
||||
m_multitouch_gui = NULL;
|
||||
} // RaceGUIBase
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Called when loading the race gui or screen resized. */
|
||||
void RaceGUIBase::initSize()
|
||||
{
|
||||
m_max_font_height = GUIEngine::getFontHeight() + 10;
|
||||
m_small_font_max_height = GUIEngine::getSmallFontHeight() + 5;
|
||||
} // initSize
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** This is a second initialisation call (after the constructor) for the race
|
||||
* gui. This is called after the world has been initialised, e.g. all karts
|
||||
@ -198,18 +205,18 @@ RaceGUIBase::~RaceGUIBase()
|
||||
} // ~RaceGUIBase
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void RaceGUIBase::recreateMultitouchGUI()
|
||||
void RaceGUIBase::recreateGUI()
|
||||
{
|
||||
if (!m_multitouch_gui)
|
||||
return;
|
||||
|
||||
m_multitouch_gui->recreate();
|
||||
if (m_multitouch_gui)
|
||||
m_multitouch_gui->recreate();
|
||||
|
||||
initSize();
|
||||
calculateMinimapSize();
|
||||
|
||||
Track* track = Track::getCurrentTrack();
|
||||
assert(track != NULL);
|
||||
track->updateMiniMapScale();
|
||||
} // recreateMultitouchGUI
|
||||
} // recreateGUI
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Creates the 2D vertices for a regular polygon. Adopted from Irrlicht.
|
||||
@ -530,7 +537,7 @@ void RaceGUIBase::update(float dt)
|
||||
cl->setSpectator(true);
|
||||
static bool msg_shown = false;
|
||||
if (getMultitouchGUI() != NULL)
|
||||
recreateMultitouchGUI();
|
||||
recreateGUI();
|
||||
else if (!msg_shown)
|
||||
{
|
||||
msg_shown = true;
|
||||
|
@ -267,7 +267,8 @@ public:
|
||||
void removeReferee();
|
||||
|
||||
RaceGUIMultitouch* getMultitouchGUI() {return m_multitouch_gui;}
|
||||
void recreateMultitouchGUI();
|
||||
void recreateGUI();
|
||||
virtual void initSize();
|
||||
|
||||
}; // RaceGUIBase
|
||||
|
||||
|
@ -105,10 +105,7 @@ RaceGUIOverworld::RaceGUIOverworld()
|
||||
|
||||
m_active_challenge = NULL;
|
||||
|
||||
// Determine maximum length of the rank/lap text, in order to
|
||||
// align those texts properly on the right side of the viewport.
|
||||
gui::ScalableFont* font = GUIEngine::getFont();
|
||||
m_trophy_points_width = font->getDimension(L"1000").Width;
|
||||
initSize();
|
||||
|
||||
m_lock = irr_driver->getTexture(FileManager::GUI_ICON,"gui_lock.png");
|
||||
m_open_challenge = irr_driver->getTexture(FileManager::GUI_ICON,"challenge.png");
|
||||
@ -123,6 +120,17 @@ RaceGUIOverworld::RaceGUIOverworld()
|
||||
m_icons[6] = m_locked_bonus;
|
||||
} // RaceGUIOverworld
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Called when loading the race gui or screen resized. */
|
||||
void RaceGUIOverworld::initSize()
|
||||
{
|
||||
RaceGUIBase::initSize();
|
||||
// Determine maximum length of the rank/lap text, in order to
|
||||
// align those texts properly on the right side of the viewport.
|
||||
gui::ScalableFont* font = GUIEngine::getFont();
|
||||
m_trophy_points_width = font->getDimension(L"1000").Width;
|
||||
} // initSize
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
RaceGUIOverworld::~RaceGUIOverworld()
|
||||
{
|
||||
|
@ -127,6 +127,7 @@ public:
|
||||
virtual const core::dimension2du getMiniMapSize() const
|
||||
{ return core::dimension2du(m_map_width, m_map_height); }
|
||||
virtual void calculateMinimapSize();
|
||||
virtual void initSize();
|
||||
|
||||
}; // RaceGUI
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user