#include "profiler.h"
#include "log.h"
#include "mods.h"
-#if USE_FREETYPE
-#include "xCGUITTFont.h"
-#endif
#include "util/string.h"
#include "subgame.h"
#include "quicktune.h"
#include "guiEngine.h"
#include "mapsector.h"
#include "player.h"
+#include "fontengine.h"
#include "database-sqlite3.h"
#ifdef USE_LEVELDB
static void list_worlds();
static void setup_log_params(const Settings &cmd_args);
static bool create_userdata_path();
-static bool init_common(int *log_level, const Settings &cmd_args);
+static bool init_common(int *log_level, const Settings &cmd_args, int argc, char *argv[]);
static void startup_message();
static bool read_config_file(const Settings &cmd_args);
static void init_debug_streams(int *log_level, const Settings &cmd_args);
}
GameParams game_params;
- if (!init_common(&game_params.log_level, cmd_args))
+ if (!init_common(&game_params.log_level, cmd_args, argc, argv))
return 1;
#ifndef __ANDROID__
porting::setExternalStorageDir(porting::jnienv);
if (!fs::PathExists(porting::path_user)) {
success = fs::CreateDir(porting::path_user);
+ } else {
+ success = true;
}
porting::copyAssets();
#else
return success;
}
-static bool init_common(int *log_level, const Settings &cmd_args)
+static bool init_common(int *log_level, const Settings &cmd_args, int argc, char *argv[])
{
startup_message();
set_default_settings(g_settings);
} else { // Otherwise we will be using "minetest"
gamespec = findSubgame(g_settings->get("default_game"));
infostream << "Using default gameid [" << gamespec.id << "]" << std::endl;
+ if (!gamespec.isValid()) {
+ errorstream << "Subgame specified in default_game ["
+ << g_settings->get("default_game")
+ << "] is invalid." << std::endl;
+ return false;
+ }
}
} else { // World exists
std::string world_gameid = getWorldGameId(game_params->world_path, false);
#if USE_REDIS
else if (migrate_to == "redis")
new_db = new Database_Redis(&(ServerMap&)server->getMap(),
- game_params.requested_world_path);
+ game_params.world_path);
#endif
else {
errorstream << "Migration to " << migrate_to << " is not supported"
if (input)
delete input;
+ if (g_fontengine)
+ delete g_fontengine;
+
if (device)
device->drop();
-
-#if USE_FREETYPE
- if (use_freetype && font != NULL)
- font->drop();
-#endif
}
+
bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
{
init_args(game_params, cmd_args);
return false;
}
- late_init_default_settings(g_settings);
-
// Speed tests (done after irrlicht is loaded to get timer)
if (cmd_args.getFlag("speedtests")) {
dstream << "Running speed tests" << std::endl;
return true;
}
- if (device->getVideoDriver() == NULL) {
+ video::IVideoDriver *video_driver = device->getVideoDriver();
+ if (video_driver == NULL) {
errorstream << "Could not initialize video driver." << std::endl;
return false;
}
+ porting::setXorgClassHint(video_driver->getExposedVideoData(), "Minetest");
+
/*
This changes the minimum allowed number of vertices in a VBO.
Default is 500.
guienv = device->getGUIEnvironment();
skin = guienv->getSkin();
- std::string font_path = g_settings->get("font_path");
-
-#if USE_FREETYPE
-
- if (use_freetype) {
- std::string fallback;
- if (is_yes(gettext("needs_fallback_font")))
- fallback = "fallback_";
- u16 font_size = g_settings->getU16(fallback + "font_size");
- font_path = g_settings->get(fallback + "font_path");
- u32 font_shadow = g_settings->getU16(fallback + "font_shadow");
- u32 font_shadow_alpha = g_settings->getU16(fallback + "font_shadow_alpha");
- font = gui::CGUITTFont::createTTFont(guienv,
- font_path.c_str(), font_size, true, true,
- font_shadow, font_shadow_alpha);
- } else {
- font = guienv->getFont(font_path.c_str());
- }
-#else
- font = guienv->getFont(font_path.c_str());
-#endif
- if (font)
- skin->setFont(font);
- else
- errorstream << "WARNING: Font file was not found. Using default font."
- << std::endl;
-
- font = skin->getFont(); // If font was not found, this will get us one
- assert(font);
-
- u32 text_height = font->getDimension(L"Hello, world!").Height;
- infostream << "text_height=" << text_height << std::endl;
-
skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 0, 0, 0));
skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0));
skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 100, 50));
skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255, 255, 255, 255));
+ g_fontengine = new FontEngine(g_settings, guienv);
+ assert(g_fontengine != NULL);
+
#if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
// Irrlicht 1.8 input colours
skin->setColor(gui::EGDC_EDITABLE, video::SColor(255, 128, 128, 128));
random_input,
input,
device,
- font,
worldspec.path,
current_playername,
current_password,
void ClientLauncher::init_args(GameParams &game_params, const Settings &cmd_args)
{
+
+ skip_main_menu = cmd_args.getFlag("go");
+
+ // FIXME: This is confusing (but correct)
+
+ /* If world_path is set then override it unless skipping the main menu using
+ * the --go command line param. Else, give preference to the address
+ * supplied on the command line
+ */
address = g_settings->get("address");
- if (game_params.world_path != "")
+ if (game_params.world_path != "" && !skip_main_menu)
address = "";
else if (cmd_args.exists("address"))
address = cmd_args.get("address");
if (cmd_args.exists("name"))
playername = cmd_args.get("name");
- skip_main_menu = cmd_args.getFlag("go");
-
list_video_modes = cmd_args.getFlag("videomodes");
use_freetype = g_settings->getBool("freetype");
errorstream << wide_to_narrow(*error_message) << std::endl;
return false;
}
+
+ if (porting::signal_handler_killstatus())
+ return true;
+
if (game_params.game_spec.isValid() &&
game_params.game_spec.id != worldspec.gameid) {
errorstream << "WARNING: Overriding gamespec from \""