#include "util/pointedthing.h"
#include "drawscene.h"
#include "content_cao.h"
+#include "fontengine.h"
#ifdef HAVE_TOUCHSCREENGUI
#include "touchscreengui.h"
/* Profiler display */
-void update_profiler_gui(gui::IGUIStaticText *guitext_profiler,
- gui::IGUIFont *font, u32 text_height, u32 show_profiler,
- u32 show_profiler_max)
+void update_profiler_gui(gui::IGUIStaticText *guitext_profiler, FontEngine *fe,
+ u32 show_profiler, u32 show_profiler_max)
{
if (show_profiler == 0) {
guitext_profiler->setVisible(false);
guitext_profiler->setText(text.c_str());
guitext_profiler->setVisible(true);
- s32 w = font->getDimension(text.c_str()).Width;
+ s32 w = fe->getTextWidth(text.c_str());
if (w < 400)
w = 400;
- core::rect<s32> rect(6, 4 + (text_height + 5) * 2, 12 + w,
- 8 + (text_height + 5) * 2 +
- font->getDimension(text.c_str()).Height);
+ core::rect<s32> rect(6, 4 + (fe->getTextHeight() + 5) * 2, 12 + w,
+ 8 + (fe->getTextHeight() + 5) * 2 +
+ fe->getTextHeight());
guitext_profiler->setRelativePosition(rect);
guitext_profiler->setVisible(true);
}
// Dont place node when player would be inside new node
// NOTE: This is to be eventually implemented by a mod as client-side Lua
if (!nodedef->get(n).walkable ||
+ g_settings->getBool("enable_build_where_you_stand") ||
(client.checkPrivilege("noclip") && g_settings->getBool("noclip")) ||
(nodedef->get(n).walkable &&
neighbourpos != player->getStandingNodePos() + v3s16(0, 1, 0) &&
/******************************************************************************/
static void updateChat(Client &client, f32 dtime, bool show_debug,
const v2u32 &screensize, bool show_chat, u32 show_profiler,
- ChatBackend &chat_backend, gui::IGUIStaticText *guitext_chat,
- gui::IGUIFont *font)
+ ChatBackend &chat_backend, gui::IGUIStaticText *guitext_chat)
{
// Add chat log output for errors to be shown in chat
static LogOutputBuffer chat_log_error_buf(LMT_ERROR);
// Display all messages in a static text element
unsigned int recent_chat_count = chat_backend.getRecentBuffer().getLineCount();
std::wstring recent_chat = chat_backend.getRecentChat();
-
- // TODO replace by fontengine fcts
- unsigned int line_height = font->getDimension(L"Ay").Height + font->getKerningHeight();
+ unsigned int line_height = g_fontengine->getLineHeight();
guitext_chat->setText(recent_chat.c_str());
chat_y += line_height;
// first pass to calculate height of text to be set
- s32 width = std::min(font->getDimension(recent_chat.c_str()).Width + 10,
+ s32 width = std::min(g_fontengine->getTextWidth(recent_chat) + 10,
porting::getWindowSize().X - 20);
core::rect<s32> rect(10, chat_y, width, chat_y + porting::getWindowSize().Y);
guitext_chat->setRelativePosition(rect);
bool random_input,
InputHandler *input,
IrrlichtDevice *device,
- gui::IGUIFont *font,
const std::string &map_dir,
const std::string &playername,
const std::string &password,
Client *client;
Server *server;
- gui::IGUIFont *font;
-
IWritableTextureSource *texture_src;
IWritableShaderSource *shader_src;
IrrlichtDevice *device;
video::IVideoDriver *driver;
scene::ISceneManager *smgr;
- u32 text_height;
bool *kill;
std::wstring *error_message;
IGameDef *gamedef; // Convenience (same as *client)
Game::Game() :
client(NULL),
server(NULL),
- font(NULL),
texture_src(NULL),
shader_src(NULL),
itemdef_manager(NULL),
bool random_input,
InputHandler *input,
IrrlichtDevice *device,
- gui::IGUIFont *font,
const std::string &map_dir,
const std::string &playername,
const std::string &password,
{
// "cache"
this->device = device;
- this->font = font;
this->kill = kill;
this->error_message = error_message;
this->random_input = random_input;
driver = device->getVideoDriver();
smgr = device->getSceneManager();
- text_height = font->getDimension(L"Random test string").Height;
if (!init(map_dir, address, port, gamespec))
return false;
}
// Update cached textures, meshes and materials
- client->afterContentReceived(device, font);
+ client->afterContentReceived(device, g_fontengine->getFont());
/* Camera
*/
player->hurt_tilt_timer = 0;
player->hurt_tilt_strength = 0;
- hud = new Hud(driver, smgr, guienv, font, text_height, gamedef,
- player, local_inventory);
+ hud = new Hud(driver, smgr, guienv, gamedef, player, local_inventory);
if (!hud) {
*error_message = L"Memory error: could not create HUD";
// Object infos are shown in this
guitext_info = guienv->addStaticText(
L"",
- core::rect<s32>(0, 0, 400, text_height * 5 + 5) + v2s32(100, 200),
+ core::rect<s32>(0, 0, 400, g_fontengine->getTextHeight() * 5 + 5) + v2s32(100, 200),
false, true, guiroot);
// Status text (displays info when showing and hiding GUI stuff, etc.)
#ifdef HAVE_TOUCHSCREENGUI
if (g_touchscreengui)
- g_touchscreengui->init(tsrc, porting::getDisplayDensity());
+ g_touchscreengui->init(texture_src, porting::getDisplayDensity());
#endif
return false;
}
- client = new Client(device, playername.c_str(), password, *draw_control,
- texture_src, shader_src, itemdef_manager, nodedef_manager, sound,
- eventmgr, connect_address.isIPv6());
+ client = new Client(device,
+ playername.c_str(), password, simple_singleplayer_mode,
+ *draw_control, texture_src, shader_src,
+ itemdef_manager, nodedef_manager, sound, eventmgr,
+ connect_address.isIPv6());
if (!client)
return false;
if (!client->itemdefReceived()) {
wchar_t *text = wgettext("Item definitions...");
progress = 0;
- draw_load_screen(text, device, guienv, font, dtime, progress);
+ draw_load_screen(text, device, guienv, dtime, progress);
delete[] text;
} else if (!client->nodedefReceived()) {
wchar_t *text = wgettext("Node definitions...");
progress = 25;
- draw_load_screen(text, device, guienv, font, dtime, progress);
+ draw_load_screen(text, device, guienv, dtime, progress);
delete[] text;
} else {
std::stringstream message;
progress = 50 + client->mediaReceiveProgress() * 50 + 0.5;
draw_load_screen(narrow_to_wide(message.str().c_str()), device,
- guienv, font, dtime, progress);
+ guienv, dtime, progress);
}
}
g_profiler->print(infostream);
}
- update_profiler_gui(guitext_profiler, font, text_height,
+ update_profiler_gui(guitext_profiler, g_fontengine,
run_data.profiler_current_page, run_data.profiler_max_page);
g_profiler->clear();
*flag = !*flag;
*statustext_time = 0;
statustext = msg[*flag];
- client->setHighlighted(client->getHighlighted(), *flag);
+ if (g_settings->getBool("enable_node_highlighting"))
+ client->setHighlighted(client->getHighlighted(), *flag);
}
*profiler_current_page = (*profiler_current_page + 1) % (profiler_max_page + 1);
// FIXME: This updates the profiler with incomplete values
- update_profiler_gui(guitext_profiler, font, text_height,
- *profiler_current_page, profiler_max_page);
+ update_profiler_gui(guitext_profiler, g_fontengine, *profiler_current_page,
+ profiler_max_page);
if (*profiler_current_page != 0) {
std::wstringstream sstr;
#ifdef HAVE_TOUCHSCREENGUI
if (g_touchscreengui) {
- camera_yaw = g_touchscreengui->getYaw();
- camera_pitch = g_touchscreengui->getPitch();
+ cam->camera_yaw = g_touchscreengui->getYaw();
+ cam->camera_pitch = g_touchscreengui->getPitch();
} else {
#endif
s32 dx = input->getMousePos().X - (driver->getScreenSize().Width / 2);
updateChat(*client, dtime, flags.show_debug, screensize,
flags.show_chat, runData->profiler_current_page,
- *chat_backend, guitext_chat, font);
+ *chat_backend, guitext_chat);
/*
Inventory
Profiler graph
*/
if (flags.show_profiler_graph)
- graph->draw(10, screensize.Y - 10, driver, font);
+ graph->draw(10, screensize.Y - 10, driver, g_fontengine->getFont());
/*
Damage flash
if (guitext->isVisible()) {
core::rect<s32> rect(
5, 5,
- screensize.X, 5 + text_height
+ screensize.X, 5 + g_fontengine->getTextHeight()
);
guitext->setRelativePosition(rect);
}
guitext2->setVisible(true);
core::rect<s32> rect(
- 5, 5 + text_height,
- screensize.X, 5 + text_height * 2
+ 5, 5 + g_fontengine->getTextHeight(),
+ screensize.X, 5 + g_fontengine->getTextHeight() * 2
);
guitext2->setRelativePosition(rect);
} else {
int percent, bool draw_clouds)
{
wchar_t *text = wgettext(msg);
- draw_load_screen(text, device, guienv, font, dtime, percent, draw_clouds);
+ draw_load_screen(text, device, guienv, dtime, percent, draw_clouds);
delete[] text;
}
bool random_input,
InputHandler *input,
IrrlichtDevice *device,
- gui::IGUIFont *font,
const std::string &map_dir,
const std::string &playername,
try {
- if (game.startup(kill, random_input, input, device, font, map_dir,
+ if (game.startup(kill, random_input, input, device, map_dir,
playername, password, &server_address, port,
&error_message, &chat_backend, gamespec,
simple_singleplayer_mode)) {