@@ -32,7 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
32
32
#include " guiVolumeChange.h"
33
33
#include " guiFormSpecMenu.h"
34
34
#include " guiTextInputMenu.h"
35
- #include " guiDeathScreen.h"
36
35
#include " tool.h"
37
36
#include " guiChatConsole.h"
38
37
#include " config.h"
@@ -182,6 +181,13 @@ struct LocalFormspecHandler : public TextDest
182
181
}
183
182
}
184
183
184
+ if (m_formname == " MT_DEATH_SCREEN" ) {
185
+ if ((fields.find (" btn_respawn" ) != fields.end ())) {
186
+ m_client->sendRespawn ();
187
+ return ;
188
+ }
189
+ }
190
+
185
191
errorstream << " LocalFormspecHandler::gotText unhandled >" << m_formname << " < event" << std::endl;
186
192
int i = 0 ;
187
193
for (std::map<std::string,std::string>::iterator iter = fields.begin ();
@@ -194,26 +200,6 @@ struct LocalFormspecHandler : public TextDest
194
200
Client *m_client;
195
201
};
196
202
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
-
217
203
/* Form update callback */
218
204
219
205
class NodeMetadataFormSource : public IFormSource
@@ -1002,6 +988,32 @@ static void show_chat_menu(FormspecFormSource* current_formspec,
1002
988
menu->drop ();
1003
989
}
1004
990
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,¤t_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
+
1005
1017
/* *****************************************************************************/
1006
1018
static void show_pause_menu (FormspecFormSource* current_formspec,
1007
1019
TextDest* current_textdest, IWritableTextureSource* tsrc,
@@ -1593,7 +1605,6 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
1593
1605
1594
1606
bool invert_mouse = g_settings->getBool (" invert_mouse" );
1595
1607
1596
- bool respawn_menu_active = false ;
1597
1608
bool update_wielded_item_trigger = true ;
1598
1609
1599
1610
bool show_hud = true ;
@@ -2384,36 +2395,18 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
2384
2395
}
2385
2396
else if (event.type == CE_DEATHSCREEN)
2386
2397
{
2387
- if (respawn_menu_active)
2388
- continue ;
2398
+ show_deathscreen (current_formspec, current_textdest,
2399
+ tsrc, device, &client) ;
2389
2400
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
-
2404
2401
chat_backend.addMessage (L" " , L" You died." );
2405
2402
2406
2403
/* Handle visualization */
2407
-
2408
2404
damage_flash = 0 ;
2409
2405
2410
2406
LocalPlayer* player = client.getEnv ().getLocalPlayer ();
2411
2407
player->hurt_tilt_timer = 0 ;
2412
2408
player->hurt_tilt_strength = 0 ;
2413
2409
2414
- /* LocalPlayer* player = client.getLocalPlayer();
2415
- player->setPosition(player->getPosition() + v3f(0,-BS,0));
2416
- camera.update(player, busytime, screensize);*/
2417
2410
}
2418
2411
else if (event.type == CE_SHOW_FORMSPEC)
2419
2412
{
0 commit comments