Allow changing font size live
This commit is contained in:
parent
d7a66f72e8
commit
660a35a468
@ -36,6 +36,8 @@
|
||||
#include "GlyphLayout.h"
|
||||
#include <array>
|
||||
|
||||
#include "../lib/irrlicht/source/Irrlicht/CGUISpriteBank.h"
|
||||
|
||||
#ifndef SERVER_ONLY
|
||||
extern "C"
|
||||
{
|
||||
@ -51,11 +53,7 @@ extern "C"
|
||||
*/
|
||||
FontWithFace::FontWithFace(const std::string& name)
|
||||
{
|
||||
m_spritebank = irr_driver->getGUI()->addEmptySpriteBank(name.c_str());
|
||||
|
||||
assert(m_spritebank != NULL);
|
||||
m_spritebank->grab();
|
||||
|
||||
m_spritebank = new irr::gui::CGUISpriteBank(irr_driver->getGUI());
|
||||
m_fallback_font = NULL;
|
||||
m_fallback_font_scale = 1.0f;
|
||||
m_glyph_max_height = 0;
|
||||
@ -63,6 +61,7 @@ FontWithFace::FontWithFace(const std::string& name)
|
||||
m_face_dpi = 40;
|
||||
m_inverse_shaping = 1.0f;
|
||||
} // FontWithFace
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Destructor. Clears the glyph page and sprite bank.
|
||||
*/
|
||||
@ -74,7 +73,6 @@ FontWithFace::~FontWithFace()
|
||||
static_cast<STKTexture*>(m_spritebank->getTexture(i)));
|
||||
}
|
||||
m_spritebank->drop();
|
||||
m_spritebank = NULL;
|
||||
|
||||
delete m_face_ttf;
|
||||
} // ~FontWithFace
|
||||
|
@ -1038,7 +1038,7 @@ namespace GUIEngine
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
void init(IrrlichtDevice* device_a, IVideoDriver* driver_a,
|
||||
AbstractStateManager* state_manager )
|
||||
AbstractStateManager* state_manager, bool loading)
|
||||
{
|
||||
g_env = device_a->getGUIEnvironment();
|
||||
g_device = device_a;
|
||||
@ -1117,10 +1117,13 @@ namespace GUIEngine
|
||||
// set event receiver
|
||||
g_device->setEventReceiver(EventHandler::get());
|
||||
|
||||
g_device->getVideoDriver()
|
||||
->beginScene(true, true, video::SColor(255,100,101,140));
|
||||
renderLoading();
|
||||
g_device->getVideoDriver()->endScene();
|
||||
if (loading)
|
||||
{
|
||||
g_device->getVideoDriver()
|
||||
->beginScene(true, true, video::SColor(255,100,101,140));
|
||||
renderLoading();
|
||||
g_device->getVideoDriver()->endScene();
|
||||
}
|
||||
} // init
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
@ -107,8 +107,10 @@ namespace GUIEngine
|
||||
* \param device An initialized irrlicht device object
|
||||
* \param driver An initialized irrlicht driver object
|
||||
* \param state_manager An instance of a class derived from abstract base AbstractStateManager
|
||||
* \param loading if it's (re-)loading the GUIEngine
|
||||
*/
|
||||
void init(irr::IrrlichtDevice* device, irr::video::IVideoDriver* driver, AbstractStateManager* state_manager);
|
||||
void init(irr::IrrlichtDevice* device, irr::video::IVideoDriver* driver,
|
||||
AbstractStateManager* state_manager, bool loading = true);
|
||||
|
||||
void cleanUp();
|
||||
|
||||
|
@ -212,7 +212,6 @@ void OptionsScreenUI::init()
|
||||
GUIEngine::SpinnerWidget* font_size = getWidget<GUIEngine::SpinnerWidget>("font_size");
|
||||
assert( font_size != NULL );
|
||||
|
||||
m_prev_font_size = UserConfigParams::m_font_size;
|
||||
int size_int = (int)roundf(UserConfigParams::m_font_size);
|
||||
if (size_int < 0 || size_int > 6)
|
||||
size_int = 3;
|
||||
@ -333,6 +332,22 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
|
||||
GUIEngine::SpinnerWidget* font_size = getWidget<GUIEngine::SpinnerWidget>("font_size");
|
||||
assert( font_size != NULL );
|
||||
UserConfigParams::m_font_size = font_size->getValue();
|
||||
GUIEngine::clear();
|
||||
GUIEngine::cleanUp();
|
||||
GUIEngine::clearScreenCache();
|
||||
delete font_manager;
|
||||
font_manager = new FontManager();
|
||||
font_manager->loadFonts();
|
||||
GUIEngine::init(irr_driver->getDevice(), irr_driver->getVideoDriver(),
|
||||
StateManager::get(), false/*loading*/);
|
||||
Screen* screen_list[] =
|
||||
{
|
||||
MainMenuScreen::getInstance(),
|
||||
OptionsScreenUI::getInstance(),
|
||||
nullptr
|
||||
};
|
||||
GUIEngine::switchToScreen(MainMenuScreen::getInstance());
|
||||
StateManager::get()->resetAndSetStack(screen_list);
|
||||
}
|
||||
else if (name == "split_screen_horizontally")
|
||||
{
|
||||
@ -354,11 +369,6 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
|
||||
|
||||
void OptionsScreenUI::tearDown()
|
||||
{
|
||||
if (m_prev_font_size != UserConfigParams::m_font_size)
|
||||
{
|
||||
irr_driver->sameRestart();
|
||||
}
|
||||
|
||||
Screen::tearDown();
|
||||
// save changes when leaving screen
|
||||
user_config->saveConfig();
|
||||
|
@ -35,7 +35,6 @@ class OptionsScreenUI : public GUIEngine::Screen, public GUIEngine::ScreenSingle
|
||||
{
|
||||
OptionsScreenUI();
|
||||
bool m_inited;
|
||||
float m_prev_font_size;
|
||||
|
||||
std::map<core::stringw, std::string> m_skins;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user