@@ -1323,6 +1323,7 @@ class Game {
1323
1323
1324
1324
void showOverlayMessage (const char *msg, float dtime, int percent,
1325
1325
bool draw_clouds = true );
1326
+ void showStatusTextSimple (const char *msg);
1326
1327
1327
1328
static void settingChangedCallback (const std::string &setting_name, void *data);
1328
1329
void readSettings ();
@@ -2555,25 +2556,29 @@ void Game::processKeyInput()
2555
2556
float volume = g_settings->getFloat (" sound_volume" );
2556
2557
if (volume < 0 .001f ) {
2557
2558
g_settings->setFloat (" sound_volume" , 1 .0f );
2558
- m_statustext = narrow_to_wide ( gettext ( " Volume changed to 100%" ) );
2559
+ showStatusTextSimple ( " Volume changed to 100%" );
2559
2560
} else {
2560
2561
g_settings->setFloat (" sound_volume" , 0 .0f );
2561
- m_statustext = narrow_to_wide ( gettext ( " Volume changed to 0%" ) );
2562
+ showStatusTextSimple ( " Volume changed to 0%" );
2562
2563
}
2563
2564
runData.statustext_time = 0 ;
2564
2565
} else if (wasKeyDown (KeyType::INC_VOLUME)) {
2565
2566
float new_volume = rangelim (g_settings->getFloat (" sound_volume" ) + 0 .1f , 0 .0f , 1 .0f );
2566
- char buf[100 ];
2567
+ wchar_t buf[100 ];
2567
2568
g_settings->setFloat (" sound_volume" , new_volume);
2568
- snprintf (buf, sizeof (buf), gettext (" Volume changed to %d%%" ), myround (new_volume * 100 ));
2569
- m_statustext = narrow_to_wide (buf);
2569
+ const wchar_t *str = wgettext (" Volume changed to %d%%" );
2570
+ swprintf (buf, sizeof (buf), str, myround (new_volume * 100 ));
2571
+ delete[] str;
2572
+ m_statustext = buf;
2570
2573
runData.statustext_time = 0 ;
2571
2574
} else if (wasKeyDown (KeyType::DEC_VOLUME)) {
2572
2575
float new_volume = rangelim (g_settings->getFloat (" sound_volume" ) - 0 .1f , 0 .0f , 1 .0f );
2573
- char buf[100 ];
2576
+ wchar_t buf[100 ];
2574
2577
g_settings->setFloat (" sound_volume" , new_volume);
2575
- snprintf (buf, sizeof (buf), gettext (" Volume changed to %d%%" ), myround (new_volume * 100 ));
2576
- m_statustext = narrow_to_wide (buf);
2578
+ const wchar_t *str = wgettext (" Volume changed to %d%%" );
2579
+ swprintf (buf, sizeof (buf), str, myround (new_volume * 100 ));
2580
+ delete[] str;
2581
+ m_statustext = buf;
2577
2582
runData.statustext_time = 0 ;
2578
2583
} else if (wasKeyDown (KeyType::CINEMATIC)) {
2579
2584
toggleCinematic ();
@@ -2731,15 +2736,20 @@ void Game::handleAndroidChatInput()
2731
2736
2732
2737
void Game::toggleFreeMove ()
2733
2738
{
2734
- static const wchar_t *msg[] = { L" free_move disabled" , L" free_move enabled" };
2735
-
2736
2739
bool free_move = !g_settings->getBool (" free_move" );
2737
2740
g_settings->set (" free_move" , bool_to_cstr (free_move));
2738
2741
2739
2742
runData.statustext_time = 0 ;
2740
- m_statustext = msg[free_move];
2741
- if (free_move && !client->checkPrivilege (" fly" ))
2742
- m_statustext += L" (note: no 'fly' privilege)" ;
2743
+
2744
+ if (free_move) {
2745
+ if (client->checkPrivilege (" fly" )) {
2746
+ showStatusTextSimple (" Fly mode enabled" );
2747
+ } else {
2748
+ showStatusTextSimple (" Fly mode enabled (note: no 'fly' privilege)" );
2749
+ }
2750
+ } else {
2751
+ showStatusTextSimple (" Fly mode disabled" );
2752
+ }
2743
2753
}
2744
2754
2745
2755
@@ -2754,17 +2764,20 @@ void Game::toggleFreeMoveAlt()
2754
2764
2755
2765
void Game::toggleFast ()
2756
2766
{
2757
- static const wchar_t *msg[] = { L" fast_move disabled" , L" fast_move enabled" };
2758
2767
bool fast_move = !g_settings->getBool (" fast_move" );
2759
2768
g_settings->set (" fast_move" , bool_to_cstr (fast_move));
2760
2769
2761
2770
runData.statustext_time = 0 ;
2762
- m_statustext = msg[fast_move];
2763
-
2764
- bool has_fast_privs = client->checkPrivilege (" fast" );
2765
2771
2766
- if (fast_move && !has_fast_privs)
2767
- m_statustext += L" (note: no 'fast' privilege)" ;
2772
+ if (fast_move) {
2773
+ if (client->checkPrivilege (" fast" )) {
2774
+ showStatusTextSimple (" Fast mode enabled" );
2775
+ } else {
2776
+ showStatusTextSimple (" Fast mode enabled (note: no 'fast' privilege)" );
2777
+ }
2778
+ } else {
2779
+ showStatusTextSimple (" Fast mode disabled" );
2780
+ }
2768
2781
2769
2782
#ifdef __ANDROID__
2770
2783
m_cache_hold_aux1 = fast_move && has_fast_privs;
@@ -2774,55 +2787,65 @@ void Game::toggleFast()
2774
2787
2775
2788
void Game::toggleNoClip ()
2776
2789
{
2777
- static const wchar_t *msg[] = { L" noclip disabled" , L" noclip enabled" };
2778
2790
bool noclip = !g_settings->getBool (" noclip" );
2779
2791
g_settings->set (" noclip" , bool_to_cstr (noclip));
2780
2792
2781
2793
runData.statustext_time = 0 ;
2782
- m_statustext = msg[noclip];
2783
-
2784
- if (noclip && !client->checkPrivilege (" noclip" ))
2785
- m_statustext += L" (note: no 'noclip' privilege)" ;
2794
+ if (noclip) {
2795
+ if (client->checkPrivilege (" noclip" )) {
2796
+ showStatusTextSimple (" Noclip mode enabled" );
2797
+ } else {
2798
+ showStatusTextSimple (" Noclip mode enabled (note: no 'noclip' privilege)" );
2799
+ }
2800
+ } else {
2801
+ showStatusTextSimple (" Noclip mode disabled" );
2802
+ }
2786
2803
}
2787
2804
2788
2805
void Game::toggleCinematic ()
2789
2806
{
2790
- static const wchar_t *msg[] = { L" cinematic disabled" , L" cinematic enabled" };
2791
2807
bool cinematic = !g_settings->getBool (" cinematic" );
2792
2808
g_settings->set (" cinematic" , bool_to_cstr (cinematic));
2793
2809
2794
2810
runData.statustext_time = 0 ;
2795
- m_statustext = msg[cinematic];
2811
+ if (cinematic)
2812
+ showStatusTextSimple (" Cinematic mode enabled" );
2813
+ else
2814
+ showStatusTextSimple (" Cinematic mode disabled" );
2796
2815
}
2797
2816
2798
2817
// Autoforward by toggling continuous forward.
2799
2818
void Game::toggleAutoforward ()
2800
2819
{
2801
- static const wchar_t *msg[] = { L" autoforward disabled" , L" autoforward enabled" };
2802
- bool autoforward_enabled = !g_settings->getBool (" continuous_forward" );
2803
- g_settings->set (" continuous_forward" , bool_to_cstr (autoforward_enabled));
2820
+ bool autorun_enabled = !g_settings->getBool (" continuous_forward" );
2821
+ g_settings->set (" continuous_forward" , bool_to_cstr (autorun_enabled));
2804
2822
2805
2823
runData.statustext_time = 0 ;
2806
- m_statustext = msg[autoforward_enabled ? 1 : 0 ];
2824
+ if (autorun_enabled)
2825
+ showStatusTextSimple (" Automatic forwards enabled" );
2826
+ else
2827
+ showStatusTextSimple (" Automatic forwards disabled" );
2807
2828
}
2808
2829
2809
2830
void Game::toggleChat ()
2810
2831
{
2811
- static const wchar_t *msg[] = { L" Chat hidden" , L" Chat shown" };
2812
-
2813
2832
flags.show_chat = !flags.show_chat ;
2814
2833
runData.statustext_time = 0 ;
2815
- m_statustext = msg[flags.show_chat ];
2834
+ if (flags.show_chat )
2835
+ showStatusTextSimple (" Chat shown" );
2836
+ else
2837
+ showStatusTextSimple (" Chat hidden" );
2816
2838
}
2817
2839
2818
2840
2819
2841
void Game::toggleHud ()
2820
2842
{
2821
- static const wchar_t *msg[] = { L" HUD hidden" , L" HUD shown" };
2822
-
2823
2843
flags.show_hud = !flags.show_hud ;
2824
2844
runData.statustext_time = 0 ;
2825
- m_statustext = msg[flags.show_hud ];
2845
+ if (flags.show_hud )
2846
+ showStatusTextSimple (" HUD shown" );
2847
+ else
2848
+ showStatusTextSimple (" HUD hidden" );
2826
2849
}
2827
2850
2828
2851
void Game::toggleMinimap (bool shift_pressed)
@@ -2849,28 +2872,30 @@ void Game::toggleMinimap(bool shift_pressed)
2849
2872
flags.show_minimap = true ;
2850
2873
switch (mode) {
2851
2874
case MINIMAP_MODE_SURFACEx1:
2852
- m_statustext = L " Minimap in surface mode, Zoom x1" ;
2875
+ showStatusTextSimple ( " Minimap in surface mode, Zoom x1" ) ;
2853
2876
break ;
2854
2877
case MINIMAP_MODE_SURFACEx2:
2855
- m_statustext = L " Minimap in surface mode, Zoom x2" ;
2878
+ showStatusTextSimple ( " Minimap in surface mode, Zoom x2" ) ;
2856
2879
break ;
2857
2880
case MINIMAP_MODE_SURFACEx4:
2858
- m_statustext = L " Minimap in surface mode, Zoom x4" ;
2881
+ showStatusTextSimple ( " Minimap in surface mode, Zoom x4" ) ;
2859
2882
break ;
2860
2883
case MINIMAP_MODE_RADARx1:
2861
- m_statustext = L " Minimap in radar mode, Zoom x1" ;
2884
+ showStatusTextSimple ( " Minimap in radar mode, Zoom x1" ) ;
2862
2885
break ;
2863
2886
case MINIMAP_MODE_RADARx2:
2864
- m_statustext = L " Minimap in radar mode, Zoom x2" ;
2887
+ showStatusTextSimple ( " Minimap in radar mode, Zoom x2" ) ;
2865
2888
break ;
2866
2889
case MINIMAP_MODE_RADARx4:
2867
- m_statustext = L " Minimap in radar mode, Zoom x4" ;
2890
+ showStatusTextSimple ( " Minimap in radar mode, Zoom x4" ) ;
2868
2891
break ;
2869
2892
default :
2870
2893
mode = MINIMAP_MODE_OFF;
2871
2894
flags.show_minimap = false ;
2872
- m_statustext = (hud_flags & HUD_FLAG_MINIMAP_VISIBLE) ?
2873
- L" Minimap hidden" : L" Minimap disabled by server" ;
2895
+ if (hud_flags & HUD_FLAG_MINIMAP_VISIBLE)
2896
+ showStatusTextSimple (" Minimap hidden" );
2897
+ else
2898
+ showStatusTextSimple (" Minimap disabled by server" );
2874
2899
}
2875
2900
2876
2901
runData.statustext_time = 0 ;
@@ -2879,11 +2904,12 @@ void Game::toggleMinimap(bool shift_pressed)
2879
2904
2880
2905
void Game::toggleFog ()
2881
2906
{
2882
- static const wchar_t *msg[] = { L" Fog enabled" , L" Fog disabled" };
2883
-
2884
2907
flags.force_fog_off = !flags.force_fog_off ;
2885
2908
runData.statustext_time = 0 ;
2886
- m_statustext = msg[flags.force_fog_off ];
2909
+ if (flags.force_fog_off )
2910
+ showStatusTextSimple (" Fog disabled" );
2911
+ else
2912
+ showStatusTextSimple (" Fog enabled" );
2887
2913
}
2888
2914
2889
2915
@@ -2897,22 +2923,22 @@ void Game::toggleDebug()
2897
2923
flags.show_debug = true ;
2898
2924
flags.show_profiler_graph = false ;
2899
2925
draw_control->show_wireframe = false ;
2900
- m_statustext = L " Debug info shown" ;
2926
+ showStatusTextSimple ( " Debug info shown" ) ;
2901
2927
} else if (!flags.show_profiler_graph && !draw_control->show_wireframe ) {
2902
2928
flags.show_profiler_graph = true ;
2903
- m_statustext = L " Profiler graph shown" ;
2929
+ showStatusTextSimple ( " Profiler graph shown" ) ;
2904
2930
} else if (!draw_control->show_wireframe && client->checkPrivilege (" debug" )) {
2905
2931
flags.show_profiler_graph = false ;
2906
2932
draw_control->show_wireframe = true ;
2907
- m_statustext = L " Wireframe shown" ;
2933
+ showStatusTextSimple ( " Wireframe shown" ) ;
2908
2934
} else {
2909
2935
flags.show_debug = false ;
2910
2936
flags.show_profiler_graph = false ;
2911
2937
draw_control->show_wireframe = false ;
2912
2938
if (client->checkPrivilege (" debug" )) {
2913
- m_statustext = L " Debug info, profiler graph, and wireframe hidden" ;
2939
+ showStatusTextSimple ( " Debug info, profiler graph, and wireframe hidden" ) ;
2914
2940
} else {
2915
- m_statustext = L " Debug info and profiler graph hidden" ;
2941
+ showStatusTextSimple ( " Debug info and profiler graph hidden" ) ;
2916
2942
}
2917
2943
}
2918
2944
runData.statustext_time = 0 ;
@@ -2921,14 +2947,12 @@ void Game::toggleDebug()
2921
2947
2922
2948
void Game::toggleUpdateCamera ()
2923
2949
{
2924
- static const wchar_t *msg[] = {
2925
- L" Camera update enabled" ,
2926
- L" Camera update disabled"
2927
- };
2928
-
2929
2950
flags.disable_camera_update = !flags.disable_camera_update ;
2930
2951
runData.statustext_time = 0 ;
2931
- m_statustext = msg[flags.disable_camera_update ];
2952
+ if (flags.disable_camera_update )
2953
+ showStatusTextSimple (" Camera update disabled" );
2954
+ else
2955
+ showStatusTextSimple (" Camera update enabled" );
2932
2956
}
2933
2957
2934
2958
@@ -2942,12 +2966,15 @@ void Game::toggleProfiler()
2942
2966
runData.profiler_max_page , driver->getScreenSize ().Height );
2943
2967
2944
2968
if (runData.profiler_current_page != 0 ) {
2945
- std::wstringstream sstr;
2946
- sstr << " Profiler shown (page " << runData.profiler_current_page
2947
- << " of " << runData.profiler_max_page << " )" ;
2948
- m_statustext = sstr.str ();
2969
+ wchar_t buf[255 ];
2970
+ const wchar_t * str = wgettext (" Profiler shown (page %d of %d)" );
2971
+ swprintf (buf, sizeof (buf), str,
2972
+ runData.profiler_current_page ,
2973
+ runData.profiler_max_page );
2974
+ delete[] str;
2975
+ m_statustext = buf;
2949
2976
} else {
2950
- m_statustext = L " Profiler hidden" ;
2977
+ showStatusTextSimple ( " Profiler hidden" ) ;
2951
2978
}
2952
2979
runData.statustext_time = 0 ;
2953
2980
}
@@ -2958,13 +2985,20 @@ void Game::increaseViewRange()
2958
2985
s16 range = g_settings->getS16 (" viewing_range" );
2959
2986
s16 range_new = range + 10 ;
2960
2987
2988
+ wchar_t buf[255 ];
2989
+ const wchar_t *str;
2961
2990
if (range_new > 4000 ) {
2962
2991
range_new = 4000 ;
2963
- m_statustext = utf8_to_wide (" Viewing range is at maximum: "
2964
- + itos (range_new));
2992
+ str = wgettext (" Viewing range is at maximum: %d" );
2993
+ swprintf (buf, sizeof (buf), str, range_new);
2994
+ delete[] str;
2995
+ m_statustext = buf;
2996
+
2965
2997
} else {
2966
- m_statustext = utf8_to_wide (" Viewing range changed to "
2967
- + itos (range_new));
2998
+ str = wgettext (" Viewing range changed to %d" );
2999
+ swprintf (buf, sizeof (buf), str, range_new);
3000
+ delete[] str;
3001
+ m_statustext = buf;
2968
3002
}
2969
3003
g_settings->set (" viewing_range" , itos (range_new));
2970
3004
runData.statustext_time = 0 ;
@@ -2976,13 +3010,19 @@ void Game::decreaseViewRange()
2976
3010
s16 range = g_settings->getS16 (" viewing_range" );
2977
3011
s16 range_new = range - 10 ;
2978
3012
3013
+ wchar_t buf[255 ];
3014
+ const wchar_t *str;
2979
3015
if (range_new < 20 ) {
2980
3016
range_new = 20 ;
2981
- m_statustext = utf8_to_wide (" Viewing range is at minimum: "
2982
- + itos (range_new));
3017
+ str = wgettext (" Viewing range is at minimum: %d" );
3018
+ swprintf (buf, sizeof (buf), str, range_new);
3019
+ delete[] str;
3020
+ m_statustext = buf;
2983
3021
} else {
2984
- m_statustext = utf8_to_wide (" Viewing range changed to "
2985
- + itos (range_new));
3022
+ str = wgettext (" Viewing range changed to %d" );
3023
+ swprintf (buf, sizeof (buf), str, range_new);
3024
+ delete[] str;
3025
+ m_statustext = buf;
2986
3026
}
2987
3027
g_settings->set (" viewing_range" , itos (range_new));
2988
3028
runData.statustext_time = 0 ;
@@ -2991,15 +3031,12 @@ void Game::decreaseViewRange()
2991
3031
2992
3032
void Game::toggleFullViewRange ()
2993
3033
{
2994
- static const wchar_t *msg[] = {
2995
- L" Normal view range" ,
2996
- L" Infinite view range"
2997
- };
2998
-
2999
3034
draw_control->range_all = !draw_control->range_all ;
3000
- infostream << msg[draw_control->range_all ] << std::endl;
3001
- m_statustext = msg[draw_control->range_all ];
3002
3035
runData.statustext_time = 0 ;
3036
+ if (draw_control->range_all )
3037
+ showStatusTextSimple (" Enabled unlimited viewing range" );
3038
+ else
3039
+ showStatusTextSimple (" Disabled unlimited viewing range" );
3003
3040
}
3004
3041
3005
3042
@@ -4558,6 +4595,13 @@ void Game::showOverlayMessage(const char *msg, float dtime, int percent, bool dr
4558
4595
delete[] wmsg;
4559
4596
}
4560
4597
4598
+ void Game::showStatusTextSimple (const char *msg)
4599
+ {
4600
+ const wchar_t *wmsg = wgettext (msg);
4601
+ m_statustext = wmsg;
4602
+ delete[] wmsg;
4603
+ }
4604
+
4561
4605
void Game::settingChangedCallback (const std::string &setting_name, void *data)
4562
4606
{
4563
4607
((Game *)data)->readSettings ();
0 commit comments