Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Replace deathscreen by formspec variant
  • Loading branch information
sapier authored and sapier committed Apr 19, 2014
1 parent eda9214 commit 0d93119
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 285 deletions.
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -449,7 +449,6 @@ set(minetest_SRCS
guiTable.cpp
guiPasswordChange.cpp
guiVolumeChange.cpp
guiDeathScreen.cpp
guiChatConsole.cpp
client.cpp
clientmedia.cpp
Expand Down
77 changes: 35 additions & 42 deletions src/game.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
{
Expand Down
182 changes: 0 additions & 182 deletions src/guiDeathScreen.cpp

This file was deleted.

60 changes: 0 additions & 60 deletions src/guiDeathScreen.h

This file was deleted.

0 comments on commit 0d93119

Please sign in to comment.