Skip to content

Commit 0d93119

Browse files
sapiersapier
sapier
authored and
sapier
committedApr 19, 2014
Replace deathscreen by formspec variant
1 parent eda9214 commit 0d93119

File tree

4 files changed

+35
-285
lines changed

4 files changed

+35
-285
lines changed
 

‎src/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,6 @@ set(minetest_SRCS
449449
guiTable.cpp
450450
guiPasswordChange.cpp
451451
guiVolumeChange.cpp
452-
guiDeathScreen.cpp
453452
guiChatConsole.cpp
454453
client.cpp
455454
clientmedia.cpp

‎src/game.cpp

+35-42
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3232
#include "guiVolumeChange.h"
3333
#include "guiFormSpecMenu.h"
3434
#include "guiTextInputMenu.h"
35-
#include "guiDeathScreen.h"
3635
#include "tool.h"
3736
#include "guiChatConsole.h"
3837
#include "config.h"
@@ -182,6 +181,13 @@ struct LocalFormspecHandler : public TextDest
182181
}
183182
}
184183

184+
if (m_formname == "MT_DEATH_SCREEN") {
185+
if ((fields.find("btn_respawn") != fields.end())) {
186+
m_client->sendRespawn();
187+
return;
188+
}
189+
}
190+
185191
errorstream << "LocalFormspecHandler::gotText unhandled >" << m_formname << "< event" << std::endl;
186192
int i = 0;
187193
for (std::map<std::string,std::string>::iterator iter = fields.begin();
@@ -194,26 +200,6 @@ struct LocalFormspecHandler : public TextDest
194200
Client *m_client;
195201
};
196202

197-
/* Respawn menu callback */
198-
199-
class MainRespawnInitiator: public IRespawnInitiator
200-
{
201-
public:
202-
MainRespawnInitiator(bool *active, Client *client):
203-
m_active(active), m_client(client)
204-
{
205-
*m_active = true;
206-
}
207-
void respawn()
208-
{
209-
*m_active = false;
210-
m_client->sendRespawn();
211-
}
212-
private:
213-
bool *m_active;
214-
Client *m_client;
215-
};
216-
217203
/* Form update callback */
218204

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

991+
static void show_deathscreen(FormspecFormSource* current_formspec,
992+
TextDest* current_textdest, IWritableTextureSource* tsrc,
993+
IrrlichtDevice * device, Client* client)
994+
{
995+
std::string formspec =
996+
std::string("") +
997+
"size[11,5.5,true]"
998+
"label[4.85,1.35;You died.]"
999+
"button_exit[4,3;3,0.5;btn_respawn;" + gettext("Respawn") + "]"
1000+
;
1001+
1002+
/* Create menu */
1003+
/* Note: FormspecFormSource and LocalFormspecHandler
1004+
* are deleted by guiFormSpecMenu */
1005+
current_formspec = new FormspecFormSource(formspec,&current_formspec);
1006+
current_textdest = new LocalFormspecHandler("MT_DEATH_SCREEN",client);
1007+
GUIFormSpecMenu *menu =
1008+
new GUIFormSpecMenu(device, guiroot, -1,
1009+
&g_menumgr,
1010+
NULL, NULL, tsrc);
1011+
menu->doPause = false;
1012+
menu->setFormSource(current_formspec);
1013+
menu->setTextDest(current_textdest);
1014+
menu->drop();
1015+
}
1016+
10051017
/******************************************************************************/
10061018
static void show_pause_menu(FormspecFormSource* current_formspec,
10071019
TextDest* current_textdest, IWritableTextureSource* tsrc,
@@ -1593,7 +1605,6 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
15931605

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

1596-
bool respawn_menu_active = false;
15971608
bool update_wielded_item_trigger = true;
15981609

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

2390-
/*bool set_camera_point_target =
2391-
event.deathscreen.set_camera_point_target;
2392-
v3f camera_point_target;
2393-
camera_point_target.X = event.deathscreen.camera_point_target_x;
2394-
camera_point_target.Y = event.deathscreen.camera_point_target_y;
2395-
camera_point_target.Z = event.deathscreen.camera_point_target_z;*/
2396-
MainRespawnInitiator *respawner =
2397-
new MainRespawnInitiator(
2398-
&respawn_menu_active, &client);
2399-
GUIDeathScreen *menu =
2400-
new GUIDeathScreen(guienv, guiroot, -1,
2401-
&g_menumgr, respawner);
2402-
menu->drop();
2403-
24042401
chat_backend.addMessage(L"", L"You died.");
24052402

24062403
/* Handle visualization */
2407-
24082404
damage_flash = 0;
24092405

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

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

‎src/guiDeathScreen.cpp

-182
This file was deleted.

‎src/guiDeathScreen.h

-60
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.