summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp49
1 files changed, 40 insertions, 9 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 1cb9a1650..6cf6723e9 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -177,8 +177,13 @@ struct LocalFormspecHandler : public TextDest
}
}
- // Don't disable this part when modding is disabled, it's used in builtin
- if (m_client && m_client->getScript())
+ if (m_formname == "MT_DEATH_SCREEN") {
+ assert(m_client != 0);
+ m_client->sendRespawn();
+ return;
+ }
+
+ if (m_client && m_client->moddingEnabled())
m_client->getScript()->on_formspec_input(m_formname, fields);
}
@@ -775,6 +780,7 @@ private:
bool disable_camera_update = false;
};
+ void showDeathFormspec();
void showPauseMenu();
// ClientEvent handlers
@@ -1496,8 +1502,6 @@ bool Game::connectToServer(const std::string &playername,
fps_control.last_time = RenderingEngine::get_timer_time();
- client->loadBuiltin();
-
while (RenderingEngine::run()) {
limitFps(&fps_control, &dtime);
@@ -1882,7 +1886,10 @@ void Game::processKeyInput()
} else if (wasKeyDown(KeyType::CMD)) {
openConsole(0.2, L"/");
} else if (wasKeyDown(KeyType::CMD_LOCAL)) {
- openConsole(0.2, L".");
+ if (client->moddingEnabled())
+ openConsole(0.2, L".");
+ else
+ m_game_ui->showStatusText(wgettext("CSM is disabled"));
} else if (wasKeyDown(KeyType::CONSOLE)) {
openConsole(core::clamp(g_settings->getFloat("console_height"), 0.1f, 1.0f));
} else if (wasKeyDown(KeyType::FREEMOVE)) {
@@ -2532,12 +2539,15 @@ void Game::handleClientEvent_PlayerForceMove(ClientEvent *event, CameraOrientati
void Game::handleClientEvent_Deathscreen(ClientEvent *event, CameraOrientation *cam)
{
- // This should be enabled for death formspec in builtin
- client->getScript()->on_death();
-
- LocalPlayer *player = client->getEnv().getLocalPlayer();
+ // If CSM enabled, deathscreen is handled by CSM code in
+ // builtin/client/init.lua
+ if (client->moddingEnabled())
+ client->getScript()->on_death();
+ else
+ showDeathFormspec();
/* Handle visualization */
+ LocalPlayer *player = client->getEnv().getLocalPlayer();
runData.damage_flash = 0;
player->hurt_tilt_timer = 0;
player->hurt_tilt_strength = 0;
@@ -4006,6 +4016,27 @@ void Game::extendedResourceCleanup()
<< " (note: irrlicht doesn't support removing renderers)" << std::endl;
}
+void Game::showDeathFormspec()
+{
+ static std::string formspec =
+ std::string(FORMSPEC_VERSION_STRING) +
+ SIZE_TAG
+ "bgcolor[#320000b4;true]"
+ "label[4.85,1.35;" + gettext("You died") + "]"
+ "button_exit[4,3;3,0.5;btn_respawn;" + gettext("Respawn") + "]"
+ ;
+
+ /* Create menu */
+ /* Note: FormspecFormSource and LocalFormspecHandler *
+ * are deleted by guiFormSpecMenu */
+ FormspecFormSource *fs_src = new FormspecFormSource(formspec);
+ LocalFormspecHandler *txt_dst = new LocalFormspecHandler("MT_DEATH_SCREEN", client);
+
+ GUIFormSpecMenu::create(current_formspec, client, &input->joystick, fs_src,
+ txt_dst, client->getFormspecPrepend());
+ current_formspec->setFocus("btn_respawn");
+}
+
#define GET_KEY_NAME(KEY) gettext(getKeySetting(#KEY).name())
void Game::showPauseMenu()
{