@@ -1063,6 +1063,52 @@ static void show_pause_menu(GUIFormSpecMenu** cur_formspec,
1063
1063
(*cur_formspec)->doPause = true ;
1064
1064
}
1065
1065
1066
+ /* *****************************************************************************/
1067
+ static void updateChat (Client& client, f32 dtime, bool show_debug,
1068
+ const v2u32& screensize, bool show_chat, u32 show_profiler,
1069
+ ChatBackend& chat_backend, gui::IGUIStaticText* guitext_chat,
1070
+ gui::IGUIFont* font)
1071
+ {
1072
+ // Add chat log output for errors to be shown in chat
1073
+ static LogOutputBuffer chat_log_error_buf (LMT_ERROR);
1074
+
1075
+ // Get new messages from error log buffer
1076
+ while (!chat_log_error_buf.empty ()) {
1077
+ chat_backend.addMessage (L" " , narrow_to_wide (chat_log_error_buf.get ()));
1078
+ }
1079
+
1080
+ // Get new messages from client
1081
+ std::wstring message;
1082
+ while (client.getChatMessage (message)) {
1083
+ chat_backend.addUnparsedMessage (message);
1084
+ }
1085
+
1086
+ // Remove old messages
1087
+ chat_backend.step (dtime);
1088
+
1089
+ // Display all messages in a static text element
1090
+ unsigned int recent_chat_count = chat_backend.getRecentBuffer ().getLineCount ();
1091
+ std::wstring recent_chat = chat_backend.getRecentChat ();
1092
+
1093
+ // TODO replace by fontengine fcts
1094
+ unsigned int line_height = font->getDimension (L" Ay" ).Height + font->getKerningHeight ();
1095
+
1096
+ guitext_chat->setText (recent_chat.c_str ());
1097
+
1098
+ // Update gui element size and position
1099
+ s32 chat_y = 5 + line_height;
1100
+ if (show_debug)
1101
+ chat_y += line_height;
1102
+
1103
+ core::rect<s32> rect (10 , chat_y, font->getDimension (recent_chat.c_str ()).Width +10 ,
1104
+ chat_y + (recent_chat_count * line_height));
1105
+
1106
+ guitext_chat->setRelativePosition (rect);
1107
+ // Don't show chat if disabled or empty or profiler is enabled
1108
+ guitext_chat->setVisible (
1109
+ show_chat && recent_chat_count != 0 && !show_profiler);
1110
+ }
1111
+
1066
1112
/* *****************************************************************************/
1067
1113
void the_game (bool &kill, bool random_input, InputHandler *input,
1068
1114
IrrlichtDevice *device, gui::IGUIFont* font, std::string map_dir,
@@ -1133,9 +1179,6 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
1133
1179
SoundMaker soundmaker (sound, nodedef);
1134
1180
soundmaker.registerReceiver (&eventmgr);
1135
1181
1136
- // Add chat log output for errors to be shown in chat
1137
- LogOutputBuffer chat_log_error_buf (LMT_ERROR);
1138
-
1139
1182
// Create UI for modifying quicktune values
1140
1183
QuicktuneShortcutter quicktune;
1141
1184
@@ -1527,24 +1570,24 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
1527
1570
gui::IGUIStaticText *guitext = guienv->addStaticText (
1528
1571
L" Minetest" ,
1529
1572
core::rect<s32>(0 , 0 , 0 , 0 ),
1530
- false , false );
1573
+ false , false , guiroot );
1531
1574
// Second line of debug text
1532
1575
gui::IGUIStaticText *guitext2 = guienv->addStaticText (
1533
1576
L" " ,
1534
1577
core::rect<s32>(0 , 0 , 0 , 0 ),
1535
- false , false );
1578
+ false , false , guiroot );
1536
1579
// At the middle of the screen
1537
1580
// Object infos are shown in this
1538
1581
gui::IGUIStaticText *guitext_info = guienv->addStaticText (
1539
1582
L" " ,
1540
1583
core::rect<s32>(0 ,0 ,400 ,text_height*5 +5 ) + v2s32 (100 ,200 ),
1541
- false , true );
1584
+ false , true , guiroot );
1542
1585
1543
1586
// Status text (displays info when showing and hiding GUI stuff, etc.)
1544
1587
gui::IGUIStaticText *guitext_status = guienv->addStaticText (
1545
1588
L" <Status>" ,
1546
1589
core::rect<s32>(0 ,0 ,0 ,0 ),
1547
- false , false );
1590
+ false , false , guiroot );
1548
1591
guitext_status->setVisible (false );
1549
1592
1550
1593
std::wstring statustext;
@@ -1555,7 +1598,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
1555
1598
L" " ,
1556
1599
core::rect<s32>(0 ,0 ,0 ,0 ),
1557
1600
// false, false); // Disable word wrap as of now
1558
- false , true );
1601
+ false , true , guiroot );
1559
1602
// Remove stale "recent" chat messages from previous connections
1560
1603
chat_backend.clearRecentChat ();
1561
1604
// Chat backend and console
@@ -1565,7 +1608,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
1565
1608
gui::IGUIStaticText *guitext_profiler = guienv->addStaticText (
1566
1609
L" <Profiler>" ,
1567
1610
core::rect<s32>(0 ,0 ,0 ,0 ),
1568
- false , false );
1611
+ false , false , guiroot );
1569
1612
guitext_profiler->setBackgroundColor (video::SColor (120 ,0 ,0 ,0 ));
1570
1613
guitext_profiler->setVisible (false );
1571
1614
guitext_profiler->setWordWrap (true );
@@ -3311,43 +3354,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
3311
3354
/*
3312
3355
Get chat messages from client
3313
3356
*/
3314
- {
3315
- // Get new messages from error log buffer
3316
- while (!chat_log_error_buf.empty ())
3317
- {
3318
- chat_backend.addMessage (L" " , narrow_to_wide (
3319
- chat_log_error_buf.get ()));
3320
- }
3321
- // Get new messages from client
3322
- std::wstring message;
3323
- while (client.getChatMessage (message))
3324
- {
3325
- chat_backend.addUnparsedMessage (message);
3326
- }
3327
- // Remove old messages
3328
- chat_backend.step (dtime);
3329
-
3330
- // Display all messages in a static text element
3331
- u32 recent_chat_count = chat_backend.getRecentBuffer ().getLineCount ();
3332
- std::wstring recent_chat = chat_backend.getRecentChat ();
3333
- guitext_chat->setText (recent_chat.c_str ());
3334
-
3335
- // Update gui element size and position
3336
- s32 chat_y = 5 +(text_height+5 );
3337
- if (show_debug)
3338
- chat_y += (text_height+5 );
3339
- core::rect<s32> rect (
3340
- 10 ,
3341
- chat_y,
3342
- screensize.X - 10 ,
3343
- chat_y + guitext_chat->getTextHeight ()
3344
- );
3345
- guitext_chat->setRelativePosition (rect);
3346
-
3347
- // Don't show chat if disabled or empty or profiler is enabled
3348
- guitext_chat->setVisible (show_chat && recent_chat_count != 0
3349
- && !show_profiler);
3350
- }
3357
+ updateChat (client, dtime, show_debug, screensize, show_chat,
3358
+ show_profiler, chat_backend, guitext_chat, font);
3351
3359
3352
3360
/*
3353
3361
Inventory
@@ -3388,6 +3396,13 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
3388
3396
update_draw_list_last_cam_dir = camera_direction;
3389
3397
}
3390
3398
3399
+ /*
3400
+ make sure menu is on top
3401
+ */
3402
+ if ((!noMenuActive ()) && (current_formspec)) {
3403
+ guiroot->bringToFront (current_formspec);
3404
+ }
3405
+
3391
3406
/*
3392
3407
Drawing begins
3393
3408
*/
0 commit comments