mirror of
https://github.com/minetest/minetest.git
synced 2024-09-12 00:26:50 +02:00
Get rid of global guienv variable
(It can already be accessed via the renderingengine.)
This commit is contained in:
parent
45e7a80057
commit
16da954bd7
@ -1776,7 +1776,6 @@ float Client::mediaReceiveProgress()
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct TextureUpdateArgs {
|
struct TextureUpdateArgs {
|
||||||
gui::IGUIEnvironment *guienv;
|
|
||||||
u64 last_time_ms;
|
u64 last_time_ms;
|
||||||
u16 last_percent;
|
u16 last_percent;
|
||||||
std::wstring text_base;
|
std::wstring text_base;
|
||||||
@ -1802,7 +1801,7 @@ void Client::showUpdateProgressTexture(void *args, u32 progress, u32 max_progres
|
|||||||
targs->last_time_ms = time_ms;
|
targs->last_time_ms = time_ms;
|
||||||
std::wostringstream strm;
|
std::wostringstream strm;
|
||||||
strm << targs->text_base << L" " << targs->last_percent << L"%...";
|
strm << targs->text_base << L" " << targs->last_percent << L"%...";
|
||||||
m_rendering_engine->draw_load_screen(strm.str(), targs->guienv, targs->tsrc, 0,
|
m_rendering_engine->draw_load_screen(strm.str(), targs->tsrc, 0,
|
||||||
72 + (u16) ((18. / 100.) * (double) targs->last_percent));
|
72 + (u16) ((18. / 100.) * (double) targs->last_percent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1822,19 +1821,19 @@ void Client::afterContentReceived()
|
|||||||
// Rebuild inherited images and recreate textures
|
// Rebuild inherited images and recreate textures
|
||||||
infostream<<"- Rebuilding images and textures"<<std::endl;
|
infostream<<"- Rebuilding images and textures"<<std::endl;
|
||||||
m_rendering_engine->draw_load_screen(wstrgettext("Loading textures..."),
|
m_rendering_engine->draw_load_screen(wstrgettext("Loading textures..."),
|
||||||
guienv, m_tsrc, 0, 70);
|
m_tsrc, 0, 70);
|
||||||
m_tsrc->rebuildImagesAndTextures();
|
m_tsrc->rebuildImagesAndTextures();
|
||||||
|
|
||||||
// Rebuild shaders
|
// Rebuild shaders
|
||||||
infostream<<"- Rebuilding shaders"<<std::endl;
|
infostream<<"- Rebuilding shaders"<<std::endl;
|
||||||
m_rendering_engine->draw_load_screen(wstrgettext("Rebuilding shaders..."),
|
m_rendering_engine->draw_load_screen(wstrgettext("Rebuilding shaders..."),
|
||||||
guienv, m_tsrc, 0, 71);
|
m_tsrc, 0, 71);
|
||||||
m_shsrc->rebuildShaders();
|
m_shsrc->rebuildShaders();
|
||||||
|
|
||||||
// Update node aliases
|
// Update node aliases
|
||||||
infostream<<"- Updating node aliases"<<std::endl;
|
infostream<<"- Updating node aliases"<<std::endl;
|
||||||
m_rendering_engine->draw_load_screen(wstrgettext("Initializing nodes..."),
|
m_rendering_engine->draw_load_screen(wstrgettext("Initializing nodes..."),
|
||||||
guienv, m_tsrc, 0, 72);
|
m_tsrc, 0, 72);
|
||||||
m_nodedef->updateAliases(m_itemdef);
|
m_nodedef->updateAliases(m_itemdef);
|
||||||
for (const auto &path : getTextureDirs()) {
|
for (const auto &path : getTextureDirs()) {
|
||||||
TextureOverrideSource override_source(path + DIR_DELIM + "override.txt");
|
TextureOverrideSource override_source(path + DIR_DELIM + "override.txt");
|
||||||
@ -1847,7 +1846,6 @@ void Client::afterContentReceived()
|
|||||||
// Update node textures and assign shaders to each tile
|
// Update node textures and assign shaders to each tile
|
||||||
infostream<<"- Updating node textures"<<std::endl;
|
infostream<<"- Updating node textures"<<std::endl;
|
||||||
TextureUpdateArgs tu_args;
|
TextureUpdateArgs tu_args;
|
||||||
tu_args.guienv = guienv;
|
|
||||||
tu_args.last_time_ms = porting::getTimeMs();
|
tu_args.last_time_ms = porting::getTimeMs();
|
||||||
tu_args.last_percent = 0;
|
tu_args.last_percent = 0;
|
||||||
tu_args.text_base = wstrgettext("Initializing nodes");
|
tu_args.text_base = wstrgettext("Initializing nodes");
|
||||||
@ -1864,7 +1862,7 @@ void Client::afterContentReceived()
|
|||||||
if (m_mods_loaded)
|
if (m_mods_loaded)
|
||||||
m_script->on_client_ready(m_env.getLocalPlayer());
|
m_script->on_client_ready(m_env.getLocalPlayer());
|
||||||
|
|
||||||
m_rendering_engine->draw_load_screen(wstrgettext("Done!"), guienv, m_tsrc, 0, 100);
|
m_rendering_engine->draw_load_screen(wstrgettext("Done!"), m_tsrc, 0, 100);
|
||||||
infostream<<"Client::afterContentReceived() done"<<std::endl;
|
infostream<<"Client::afterContentReceived() done"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
/* mainmenumanager.h
|
/* mainmenumanager.h
|
||||||
*/
|
*/
|
||||||
gui::IGUIEnvironment *guienv = nullptr;
|
|
||||||
MainMenuManager g_menumgr;
|
MainMenuManager g_menumgr;
|
||||||
|
|
||||||
bool isMenuActive()
|
bool isMenuActive()
|
||||||
@ -135,7 +134,7 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
|||||||
m_rendering_engine->get_scene_manager()->getParameters()->
|
m_rendering_engine->get_scene_manager()->getParameters()->
|
||||||
setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
|
setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
|
||||||
|
|
||||||
guienv = m_rendering_engine->get_gui_env();
|
gui::IGUIEnvironment *guienv = m_rendering_engine->get_gui_env();
|
||||||
skin = guienv->getSkin();
|
skin = guienv->getSkin();
|
||||||
skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
|
skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
|
||||||
skin->setColor(gui::EGDC_3D_LIGHT, video::SColor(0, 0, 0, 0));
|
skin->setColor(gui::EGDC_3D_LIGHT, video::SColor(0, 0, 0, 0));
|
||||||
|
@ -1530,7 +1530,9 @@ bool Game::createClient(const GameStartData &start_data)
|
|||||||
|
|
||||||
bool Game::initGui()
|
bool Game::initGui()
|
||||||
{
|
{
|
||||||
m_game_ui->init();
|
auto guienv = m_rendering_engine->get_gui_env();
|
||||||
|
|
||||||
|
m_game_ui->init(guienv);
|
||||||
|
|
||||||
// Remove stale "recent" chat messages from previous connections
|
// Remove stale "recent" chat messages from previous connections
|
||||||
chat_backend->clearRecentChat();
|
chat_backend->clearRecentChat();
|
||||||
@ -1725,11 +1727,11 @@ bool Game::getServerContent(bool *aborted)
|
|||||||
if (!client->itemdefReceived()) {
|
if (!client->itemdefReceived()) {
|
||||||
progress = 25;
|
progress = 25;
|
||||||
m_rendering_engine->draw_load_screen(wstrgettext("Item definitions..."),
|
m_rendering_engine->draw_load_screen(wstrgettext("Item definitions..."),
|
||||||
guienv, texture_src, dtime, progress);
|
texture_src, dtime, progress);
|
||||||
} else if (!client->nodedefReceived()) {
|
} else if (!client->nodedefReceived()) {
|
||||||
progress = 30;
|
progress = 30;
|
||||||
m_rendering_engine->draw_load_screen(wstrgettext("Node definitions..."),
|
m_rendering_engine->draw_load_screen(wstrgettext("Node definitions..."),
|
||||||
guienv, texture_src, dtime, progress);
|
texture_src, dtime, progress);
|
||||||
} else {
|
} else {
|
||||||
std::ostringstream message;
|
std::ostringstream message;
|
||||||
std::fixed(message);
|
std::fixed(message);
|
||||||
@ -1754,7 +1756,7 @@ bool Game::getServerContent(bool *aborted)
|
|||||||
}
|
}
|
||||||
|
|
||||||
progress = 30 + client->mediaReceiveProgress() * 35 + 0.5;
|
progress = 30 + client->mediaReceiveProgress() * 35 + 0.5;
|
||||||
m_rendering_engine->draw_load_screen(utf8_to_wide(message.str()), guienv,
|
m_rendering_engine->draw_load_screen(utf8_to_wide(message.str()),
|
||||||
texture_src, dtime, progress);
|
texture_src, dtime, progress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1805,20 +1807,23 @@ inline bool Game::handleCallbacks()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto guienv = m_rendering_engine->get_gui_env();
|
||||||
|
auto guiroot = guienv->getRootGUIElement();
|
||||||
|
|
||||||
if (g_gamecallback->changepassword_requested) {
|
if (g_gamecallback->changepassword_requested) {
|
||||||
(new GUIPasswordChange(guienv, guienv->getRootGUIElement(), -1,
|
(new GUIPasswordChange(guienv, guiroot, -1,
|
||||||
&g_menumgr, client, texture_src))->drop();
|
&g_menumgr, client, texture_src))->drop();
|
||||||
g_gamecallback->changepassword_requested = false;
|
g_gamecallback->changepassword_requested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_gamecallback->changevolume_requested) {
|
if (g_gamecallback->changevolume_requested) {
|
||||||
(new GUIVolumeChange(guienv, guienv->getRootGUIElement(), -1,
|
(new GUIVolumeChange(guienv, guiroot, -1,
|
||||||
&g_menumgr, texture_src))->drop();
|
&g_menumgr, texture_src))->drop();
|
||||||
g_gamecallback->changevolume_requested = false;
|
g_gamecallback->changevolume_requested = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_gamecallback->keyconfig_requested) {
|
if (g_gamecallback->keyconfig_requested) {
|
||||||
(new GUIKeyChangeMenu(guienv, guienv->getRootGUIElement(), -1,
|
(new GUIKeyChangeMenu(guienv, guiroot, -1,
|
||||||
&g_menumgr, texture_src))->drop();
|
&g_menumgr, texture_src))->drop();
|
||||||
g_gamecallback->keyconfig_requested = false;
|
g_gamecallback->keyconfig_requested = false;
|
||||||
}
|
}
|
||||||
@ -1949,6 +1954,8 @@ void Game::updateStats(RunStats *stats, const FpsControl &draw_times,
|
|||||||
|
|
||||||
void Game::processUserInput(f32 dtime)
|
void Game::processUserInput(f32 dtime)
|
||||||
{
|
{
|
||||||
|
auto guienv = m_rendering_engine->get_gui_env();
|
||||||
|
|
||||||
// Reset input if window not active or some menu is active
|
// Reset input if window not active or some menu is active
|
||||||
if (!device->isWindowActive() || isMenuActive() || guienv->hasFocus(gui_chat_console)) {
|
if (!device->isWindowActive() || isMenuActive() || guienv->hasFocus(gui_chat_console)) {
|
||||||
if(m_game_focused) {
|
if(m_game_focused) {
|
||||||
@ -4282,7 +4289,7 @@ void FpsControl::limit(IrrlichtDevice *device, f32 *dtime)
|
|||||||
|
|
||||||
void Game::showOverlayMessage(const char *msg, float dtime, int percent, bool draw_sky)
|
void Game::showOverlayMessage(const char *msg, float dtime, int percent, bool draw_sky)
|
||||||
{
|
{
|
||||||
m_rendering_engine->draw_load_screen(wstrgettext(msg), guienv, texture_src,
|
m_rendering_engine->draw_load_screen(wstrgettext(msg), texture_src,
|
||||||
dtime, percent, draw_sky);
|
dtime, percent, draw_sky);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,17 +43,12 @@ inline static const char *yawToDirectionString(int yaw)
|
|||||||
return direction[yaw];
|
return direction[yaw];
|
||||||
}
|
}
|
||||||
|
|
||||||
GameUI::GameUI()
|
void GameUI::init(gui::IGUIEnvironment *guienv)
|
||||||
{
|
{
|
||||||
if (guienv && guienv->getSkin())
|
if (guienv->getSkin())
|
||||||
m_statustext_initial_color = guienv->getSkin()->getColor(gui::EGDC_BUTTON_TEXT);
|
m_statustext_initial_color = guienv->getSkin()->getColor(gui::EGDC_BUTTON_TEXT);
|
||||||
else
|
|
||||||
m_statustext_initial_color = video::SColor(255, 0, 0, 0);
|
|
||||||
|
|
||||||
}
|
gui::IGUIElement *guiroot = guienv->getRootGUIElement();
|
||||||
void GameUI::init()
|
|
||||||
{
|
|
||||||
IGUIElement *guiroot = guienv->getRootGUIElement();
|
|
||||||
|
|
||||||
// First line of debug text
|
// First line of debug text
|
||||||
m_guitext = gui::StaticText::add(guienv, utf8_to_wide(PROJECT_NAME_C).c_str(),
|
m_guitext = gui::StaticText::add(guienv, utf8_to_wide(PROJECT_NAME_C).c_str(),
|
||||||
|
@ -49,9 +49,6 @@ class GameUI
|
|||||||
friend class TestGameUI;
|
friend class TestGameUI;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameUI();
|
|
||||||
~GameUI() = default;
|
|
||||||
|
|
||||||
// Flags that can, or may, change during main game loop
|
// Flags that can, or may, change during main game loop
|
||||||
struct Flags
|
struct Flags
|
||||||
{
|
{
|
||||||
@ -63,7 +60,7 @@ public:
|
|||||||
bool show_profiler_graph = false;
|
bool show_profiler_graph = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
void init();
|
void init(gui::IGUIEnvironment *m_guienv);
|
||||||
void update(const RunStats &stats, Client *client, MapDrawControl *draw_control,
|
void update(const RunStats &stats, Client *client, MapDrawControl *draw_control,
|
||||||
const CameraOrientation &cam, const PointedThing &pointed_old,
|
const CameraOrientation &cam, const PointedThing &pointed_old,
|
||||||
const GUIChatConsole *chat_console, float dtime);
|
const GUIChatConsole *chat_console, float dtime);
|
||||||
@ -121,7 +118,7 @@ private:
|
|||||||
gui::IGUIStaticText *m_guitext_status = nullptr;
|
gui::IGUIStaticText *m_guitext_status = nullptr;
|
||||||
std::wstring m_statustext;
|
std::wstring m_statustext;
|
||||||
float m_statustext_time = 0.0f;
|
float m_statustext_time = 0.0f;
|
||||||
video::SColor m_statustext_initial_color;
|
video::SColor m_statustext_initial_color = video::SColor(255, 0, 0, 0);
|
||||||
|
|
||||||
gui::IGUIStaticText *m_guitext_chat = nullptr; // Chat text
|
gui::IGUIStaticText *m_guitext_chat = nullptr; // Chat text
|
||||||
u32 m_recent_chat_count = 0;
|
u32 m_recent_chat_count = 0;
|
||||||
|
@ -226,9 +226,9 @@ bool RenderingEngine::setWindowIcon()
|
|||||||
Additionally, a progressbar can be drawn when percent is set between 0 and 100.
|
Additionally, a progressbar can be drawn when percent is set between 0 and 100.
|
||||||
*/
|
*/
|
||||||
void RenderingEngine::draw_load_screen(const std::wstring &text,
|
void RenderingEngine::draw_load_screen(const std::wstring &text,
|
||||||
gui::IGUIEnvironment *guienv, ITextureSource *tsrc, float dtime,
|
ITextureSource *tsrc, float dtime, int percent, bool sky)
|
||||||
int percent, bool sky)
|
|
||||||
{
|
{
|
||||||
|
gui::IGUIEnvironment *guienv = get_gui_env();
|
||||||
v2u32 screensize = getWindowSize();
|
v2u32 screensize = getWindowSize();
|
||||||
|
|
||||||
v2s32 textsize(g_fontengine->getTextWidth(text), g_fontengine->getLineHeight());
|
v2s32 textsize(g_fontengine->getTextWidth(text), g_fontengine->getLineHeight());
|
||||||
|
@ -110,8 +110,7 @@ public:
|
|||||||
return m_device->getGUIEnvironment();
|
return m_device->getGUIEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw_load_screen(const std::wstring &text,
|
void draw_load_screen(const std::wstring &text, ITextureSource *tsrc,
|
||||||
gui::IGUIEnvironment *guienv, ITextureSource *tsrc,
|
|
||||||
float dtime = 0, int percent = 0, bool sky = true);
|
float dtime = 0, int percent = 0, bool sky = true);
|
||||||
|
|
||||||
void draw_scene(video::SColor skycolor, bool show_hud,
|
void draw_scene(video::SColor skycolor, bool show_hud,
|
||||||
|
@ -38,9 +38,6 @@ public:
|
|||||||
virtual void signalKeyConfigChange() = 0;
|
virtual void signalKeyConfigChange() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: do we really need this global variable?
|
|
||||||
extern gui::IGUIEnvironment *guienv;
|
|
||||||
|
|
||||||
// Handler for the modal menus
|
// Handler for the modal menus
|
||||||
|
|
||||||
class MainMenuManager : public IMenuManager
|
class MainMenuManager : public IMenuManager
|
||||||
|
Loading…
Reference in New Issue
Block a user