Skip to content
Permalink
Browse files

Replace deathscreen by formspec variant

  • Loading branch information...
sapier sapier
sapier authored and sapier committed Mar 19, 2014
1 parent eda9214 commit 0d93119040d2a9eb092882a09a8571f089d7c06d
Showing with 35 additions and 285 deletions.
  1. +0 −1 src/CMakeLists.txt
  2. +35 −42 src/game.cpp
  3. +0 −182 src/guiDeathScreen.cpp
  4. +0 −60 src/guiDeathScreen.h
@@ -449,7 +449,6 @@ set(minetest_SRCS
guiTable.cpp
guiPasswordChange.cpp
guiVolumeChange.cpp
guiDeathScreen.cpp
guiChatConsole.cpp
client.cpp
clientmedia.cpp
@@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "guiVolumeChange.h"
#include "guiFormSpecMenu.h"
#include "guiTextInputMenu.h"
#include "guiDeathScreen.h"
#include "tool.h"
#include "guiChatConsole.h"
#include "config.h"
@@ -182,6 +181,13 @@ struct LocalFormspecHandler : public TextDest
}
}

if (m_formname == "MT_DEATH_SCREEN") {
if ((fields.find("btn_respawn") != fields.end())) {
m_client->sendRespawn();
return;
}
}

errorstream << "LocalFormspecHandler::gotText unhandled >" << m_formname << "< event" << std::endl;
int i = 0;
for (std::map<std::string,std::string>::iterator iter = fields.begin();
@@ -194,26 +200,6 @@ struct LocalFormspecHandler : public TextDest
Client *m_client;
};

/* Respawn menu callback */

class MainRespawnInitiator: public IRespawnInitiator
{
public:
MainRespawnInitiator(bool *active, Client *client):
m_active(active), m_client(client)
{
*m_active = true;
}
void respawn()
{
*m_active = false;
m_client->sendRespawn();
}
private:
bool *m_active;
Client *m_client;
};

/* Form update callback */

class NodeMetadataFormSource: public IFormSource
@@ -1002,6 +988,32 @@ static void show_chat_menu(FormspecFormSource* current_formspec,
menu->drop();
}

static void show_deathscreen(FormspecFormSource* current_formspec,
TextDest* current_textdest, IWritableTextureSource* tsrc,
IrrlichtDevice * device, Client* client)
{
std::string formspec =
std::string("") +
"size[11,5.5,true]"
"label[4.85,1.35;You died.]"
"button_exit[4,3;3,0.5;btn_respawn;" + gettext("Respawn") + "]"
;

/* Create menu */
/* Note: FormspecFormSource and LocalFormspecHandler
* are deleted by guiFormSpecMenu */
current_formspec = new FormspecFormSource(formspec,&current_formspec);
current_textdest = new LocalFormspecHandler("MT_DEATH_SCREEN",client);
GUIFormSpecMenu *menu =
new GUIFormSpecMenu(device, guiroot, -1,
&g_menumgr,
NULL, NULL, tsrc);
menu->doPause = false;
menu->setFormSource(current_formspec);
menu->setTextDest(current_textdest);
menu->drop();
}

/******************************************************************************/
static void show_pause_menu(FormspecFormSource* current_formspec,
TextDest* current_textdest, IWritableTextureSource* tsrc,
@@ -1593,7 +1605,6 @@ void the_game(bool &kill, bool random_input, InputHandler *input,

bool invert_mouse = g_settings->getBool("invert_mouse");

bool respawn_menu_active = false;
bool update_wielded_item_trigger = true;

bool show_hud = true;
@@ -2384,36 +2395,18 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
}
else if(event.type == CE_DEATHSCREEN)
{
if(respawn_menu_active)
continue;
show_deathscreen(current_formspec, current_textdest,
tsrc, device, &client);

/*bool set_camera_point_target =
event.deathscreen.set_camera_point_target;
v3f camera_point_target;
camera_point_target.X = event.deathscreen.camera_point_target_x;
camera_point_target.Y = event.deathscreen.camera_point_target_y;
camera_point_target.Z = event.deathscreen.camera_point_target_z;*/
MainRespawnInitiator *respawner =
new MainRespawnInitiator(
&respawn_menu_active, &client);
GUIDeathScreen *menu =
new GUIDeathScreen(guienv, guiroot, -1,
&g_menumgr, respawner);
menu->drop();

chat_backend.addMessage(L"", L"You died.");

/* Handle visualization */

damage_flash = 0;

LocalPlayer* player = client.getEnv().getLocalPlayer();
player->hurt_tilt_timer = 0;
player->hurt_tilt_strength = 0;

/*LocalPlayer* player = client.getLocalPlayer();
player->setPosition(player->getPosition() + v3f(0,-BS,0));
camera.update(player, busytime, screensize);*/
}
else if (event.type == CE_SHOW_FORMSPEC)
{

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.

0 comments on commit 0d93119

Please sign in to comment.
You can’t perform that action at this time.