+ }
+}
+
+
+void Game::dropSelectedItem()
+{
+ IDropAction *a = new IDropAction();
+ a->count = 0;
+ a->from_inv.setCurrentPlayer();
+ a->from_list = "main";
+ a->from_i = client->getPlayerItem();
+ client->inventoryAction(a);
+}
+
+
+void Game::openInventory()
+{
+ /*
+ * Don't permit to open inventory is CAO or player doesn't exists.
+ * This prevent showing an empty inventory at player load
+ */
+
+ LocalPlayer *player = client->getEnv().getLocalPlayer();
+ if (player == NULL || player->getCAO() == NULL)
+ return;
+
+ infostream << "the_game: " << "Launching inventory" << std::endl;
+
+ PlayerInventoryFormSource *fs_src = new PlayerInventoryFormSource(client);
+ TextDest *txt_dst = new TextDestPlayerInventory(client);
+
+ create_formspec_menu(¤t_formspec, client, gamedef, texture_src,
+ device, fs_src, txt_dst, client);
+
+ InventoryLocation inventoryloc;
+ inventoryloc.setCurrentPlayer();
+ current_formspec->setFormSpec(fs_src->getForm(), inventoryloc);
+}
+
+
+void Game::openConsole()
+{
+ if (!gui_chat_console->isOpenInhibited()) {
+ // Open up to over half of the screen
+ gui_chat_console->openConsole(0.6);
+ guienv->setFocus(gui_chat_console);
+ }
+}
+
+
+void Game::toggleFreeMove(float *statustext_time)
+{
+ static const wchar_t *msg[] = { L"free_move disabled", L"free_move enabled" };
+
+ bool free_move = !g_settings->getBool("free_move");
+ g_settings->set("free_move", bool_to_cstr(free_move));
+
+ *statustext_time = 0;
+ statustext = msg[free_move];
+ if (free_move && !client->checkPrivilege("fly"))
+ statustext += L" (note: no 'fly' privilege)";
+}
+
+
+void Game::toggleFreeMoveAlt(float *statustext_time, float *jump_timer)
+{
+ if (m_cache_doubletap_jump && *jump_timer < 0.2f)
+ toggleFreeMove(statustext_time);
+}
+
+
+void Game::toggleFast(float *statustext_time)
+{
+ static const wchar_t *msg[] = { L"fast_move disabled", L"fast_move enabled" };
+ bool fast_move = !g_settings->getBool("fast_move");
+ g_settings->set("fast_move", bool_to_cstr(fast_move));
+
+ *statustext_time = 0;
+ statustext = msg[fast_move];
+
+ if (fast_move && !client->checkPrivilege("fast"))
+ statustext += L" (note: no 'fast' privilege)";
+}
+
+
+void Game::toggleNoClip(float *statustext_time)
+{
+ static const wchar_t *msg[] = { L"noclip disabled", L"noclip enabled" };
+ bool noclip = !g_settings->getBool("noclip");
+ g_settings->set("noclip", bool_to_cstr(noclip));
+
+ *statustext_time = 0;
+ statustext = msg[noclip];
+
+ if (noclip && !client->checkPrivilege("noclip"))
+ statustext += L" (note: no 'noclip' privilege)";
+}
+
+
+void Game::toggleChat(float *statustext_time, bool *flag)
+{
+ static const wchar_t *msg[] = { L"Chat hidden", L"Chat shown" };
+
+ *flag = !*flag;
+ *statustext_time = 0;
+ statustext = msg[*flag];
+}
+
+
+void Game::toggleHud(float *statustext_time, bool *flag)
+{
+ static const wchar_t *msg[] = { L"HUD hidden", L"HUD shown" };
+
+ *flag = !*flag;
+ *statustext_time = 0;
+ statustext = msg[*flag];
+ if (g_settings->getBool("enable_node_highlighting"))
+ client->setHighlighted(client->getHighlighted(), *flag);
+}
+
+
+void Game::toggleFog(float *statustext_time, bool *flag)
+{
+ static const wchar_t *msg[] = { L"Fog enabled", L"Fog disabled" };
+
+ *flag = !*flag;
+ *statustext_time = 0;
+ statustext = msg[*flag];
+}
+
+
+void Game::toggleDebug(float *statustext_time, bool *show_debug,
+ bool *show_profiler_graph)
+{
+ // Initial / 3x toggle: Chat only
+ // 1x toggle: Debug text with chat
+ // 2x toggle: Debug text with profiler graph
+ if (!*show_debug) {
+ *show_debug = true;
+ *show_profiler_graph = false;
+ statustext = L"Debug info shown";
+ } else if (*show_profiler_graph) {
+ *show_debug = false;
+ *show_profiler_graph = false;
+ statustext = L"Debug info and profiler graph hidden";
+ } else {
+ *show_profiler_graph = true;
+ statustext = L"Profiler graph shown";
+ }
+ *statustext_time = 0;
+}
+
+
+void Game::toggleUpdateCamera(float *statustext_time, bool *flag)
+{
+ static const wchar_t *msg[] = {
+ L"Camera update enabled",
+ L"Camera update disabled"
+ };
+
+ *flag = !*flag;
+ *statustext_time = 0;
+ statustext = msg[*flag];
+}
+
+
+void Game::toggleProfiler(float *statustext_time, u32 *profiler_current_page,
+ u32 profiler_max_page)
+{
+ *profiler_current_page = (*profiler_current_page + 1) % (profiler_max_page + 1);
+
+ // FIXME: This updates the profiler with incomplete values
+ update_profiler_gui(guitext_profiler, g_fontengine, *profiler_current_page,
+ profiler_max_page, driver->getScreenSize().Height);
+
+ if (*profiler_current_page != 0) {
+ std::wstringstream sstr;
+ sstr << "Profiler shown (page " << *profiler_current_page
+ << " of " << profiler_max_page << ")";
+ statustext = sstr.str();
+ } else {
+ statustext = L"Profiler hidden";
+ }
+ *statustext_time = 0;
+}
+
+
+void Game::increaseViewRange(float *statustext_time)
+{
+ s16 range = g_settings->getS16("viewing_range_nodes_min");
+ s16 range_new = range + 10;
+ g_settings->set("viewing_range_nodes_min", itos(range_new));
+ statustext = narrow_to_wide("Minimum viewing range changed to "
+ + itos(range_new));
+ *statustext_time = 0;
+}
+
+
+void Game::decreaseViewRange(float *statustext_time)
+{
+ s16 range = g_settings->getS16("viewing_range_nodes_min");
+ s16 range_new = range - 10;
+
+ if (range_new < 0)
+ range_new = range;
+
+ g_settings->set("viewing_range_nodes_min", itos(range_new));
+ statustext = narrow_to_wide("Minimum viewing range changed to "
+ + itos(range_new));
+ *statustext_time = 0;
+}
+
+
+void Game::toggleFullViewRange(float *statustext_time)
+{
+ static const wchar_t *msg[] = {
+ L"Disabled full viewing range",
+ L"Enabled full viewing range"
+ };
+
+ draw_control->range_all = !draw_control->range_all;
+ infostream << msg[draw_control->range_all] << std::endl;
+ statustext = msg[draw_control->range_all];
+ *statustext_time = 0;
+}
+
+
+void Game::updateCameraDirection(CameraOrientation *cam,
+ VolatileRunFlags *flags)
+{
+ if ((device->isWindowActive() && noMenuActive()) || random_input) {
+
+#ifndef __ANDROID__
+ if (!random_input) {
+ // Mac OSX gets upset if this is set every frame
+ if (device->getCursorControl()->isVisible())
+ device->getCursorControl()->setVisible(false);