@@ -411,29 +411,24 @@ void GUIFormSpecMenu::parseCheckbox(parserData* data,std::string element) {
411
411
if (selected == " true" )
412
412
fselected = true ;
413
413
414
- wchar_t * wlabel = 0 ;
414
+ std::wstring wlabel = narrow_to_wide (label. c_str ()) ;
415
415
416
416
if (m_use_gettext)
417
- wlabel = wgettext (label.c_str ());
418
- else
419
- wlabel = (wchar_t *) narrow_to_wide (label.c_str ()).c_str ();
417
+ wlabel = wstrgettext (label);
420
418
421
419
FieldSpec spec = FieldSpec (
422
420
narrow_to_wide (name.c_str ()),
423
- narrow_to_wide ( " " ) ,
421
+ L" " ,
424
422
wlabel,
425
423
258 +m_fields.size ()
426
424
);
427
425
428
426
spec.ftype = f_CheckBox;
429
-
427
+ spec. flabel = wlabel; // Needed for displaying text on MSVC
430
428
gui::IGUICheckBox* e = Environment->addCheckBox (fselected, rect, this ,
431
- spec.fid , wlabel);
432
-
429
+ spec.fid , spec.flabel .c_str ());
433
430
m_checkboxes.push_back (std::pair<FieldSpec,gui::IGUICheckBox*>(spec,e));
434
431
m_fields.push_back (spec);
435
- if (m_use_gettext)
436
- delete[] wlabel;
437
432
return ;
438
433
}
439
434
errorstream<< " Invalid checkbox element(" << parts.size () << " ): '" << element << " '" << std::endl;
@@ -547,17 +542,15 @@ void GUIFormSpecMenu::parseButton(parserData* data,std::string element,std::stri
547
542
548
543
label = unescape_string (label);
549
544
550
- wchar_t * wlabel = 0 ;
545
+ std::wstring wlabel = narrow_to_wide (label. c_str ()) ;
551
546
552
547
if (m_use_gettext)
553
- wlabel = wgettext (label.c_str ());
554
- else
555
- wlabel = (wchar_t *) narrow_to_wide (label.c_str ()).c_str ();
548
+ wlabel = wstrgettext (label);
556
549
557
550
FieldSpec spec = FieldSpec (
558
551
narrow_to_wide (name.c_str ()),
559
552
wlabel,
560
- narrow_to_wide ( " " ) ,
553
+ L" " ,
561
554
258 +m_fields.size ()
562
555
);
563
556
spec.ftype = f_Button;
@@ -566,8 +559,6 @@ void GUIFormSpecMenu::parseButton(parserData* data,std::string element,std::stri
566
559
567
560
Environment->addButton (rect, this , spec.fid , spec.flabel .c_str ());
568
561
m_fields.push_back (spec);
569
- if (m_use_gettext)
570
- delete[] wlabel;
571
562
return ;
572
563
}
573
564
errorstream<< " Invalid button element(" << parts.size () << " ): '" << element << " '" << std::endl;
@@ -639,8 +630,8 @@ void GUIFormSpecMenu::parseTextList(parserData* data,std::string element) {
639
630
640
631
FieldSpec spec = FieldSpec (
641
632
fname_w,
642
- narrow_to_wide ( " " ) ,
643
- narrow_to_wide ( " " ) ,
633
+ L" " ,
634
+ L" " ,
644
635
258 +m_fields.size ()
645
636
);
646
637
@@ -720,8 +711,8 @@ void GUIFormSpecMenu::parseDropDown(parserData* data,std::string element) {
720
711
721
712
FieldSpec spec = FieldSpec (
722
713
fname_w,
723
- narrow_to_wide ( " " ) ,
724
- narrow_to_wide ( " " ) ,
714
+ L" " ,
715
+ L" " ,
725
716
258 +m_fields.size ()
726
717
);
727
718
@@ -782,21 +773,19 @@ void GUIFormSpecMenu::parsePwdField(parserData* data,std::string element) {
782
773
783
774
label = unescape_string (label);
784
775
785
- wchar_t * wlabel = 0 ;
776
+ std::wstring wlabel = narrow_to_wide (label. c_str ()) ;
786
777
787
778
if (m_use_gettext) {
788
779
if (label.length () > 1 )
789
- wlabel = wgettext (label. c_str () );
780
+ wlabel = wstrgettext (label);
790
781
else
791
- wlabel = ( wchar_t *) narrow_to_wide ( " " ). c_str () ;
782
+ wlabel = L" " ;
792
783
}
793
- else
794
- wlabel = (wchar_t *) narrow_to_wide (label.c_str ()).c_str ();
795
784
796
785
FieldSpec spec = FieldSpec (
797
786
narrow_to_wide (name.c_str ()),
798
787
wlabel,
799
- narrow_to_wide ( " " ) ,
788
+ L" " ,
800
789
258 +m_fields.size ()
801
790
);
802
791
@@ -819,8 +808,6 @@ void GUIFormSpecMenu::parsePwdField(parserData* data,std::string element) {
819
808
evt.KeyInput .PressedDown = true ;
820
809
e->OnEvent (evt);
821
810
m_fields.push_back (spec);
822
- if ((m_use_gettext) && (label.length () >1 ))
823
- delete[] wlabel;
824
811
return ;
825
812
}
826
813
errorstream<< " Invalid pwdfield element(" << parts.size () << " ): '" << element << " '" << std::endl;
@@ -862,16 +849,14 @@ void GUIFormSpecMenu::parseSimpleField(parserData* data,std::vector<std::string>
862
849
default_val = unescape_string (default_val);
863
850
label = unescape_string (label);
864
851
865
- wchar_t * wlabel = 0 ;
852
+ std::wstring wlabel = narrow_to_wide (label. c_str ()) ;
866
853
867
854
if (m_use_gettext) {
868
855
if (label.length () > 1 )
869
- wlabel = wgettext (label. c_str () );
856
+ wlabel = wstrgettext (label);
870
857
else
871
- wlabel = ( wchar_t *) narrow_to_wide ( " " ). c_str () ;
858
+ wlabel = L" " ;
872
859
}
873
- else
874
- wlabel = (wchar_t *) narrow_to_wide (label.c_str ()).c_str ();
875
860
876
861
FieldSpec spec = FieldSpec (
877
862
narrow_to_wide (name.c_str ()),
@@ -904,8 +889,6 @@ void GUIFormSpecMenu::parseSimpleField(parserData* data,std::vector<std::string>
904
889
Environment->addStaticText (spec.flabel .c_str (), rect, false , true , this , 0 );
905
890
}
906
891
}
907
- if (m_use_gettext && (label.length () > 1 ))
908
- delete[] wlabel;
909
892
910
893
m_fields.push_back (spec);
911
894
}
@@ -953,16 +936,14 @@ void GUIFormSpecMenu::parseTextArea(parserData* data,std::vector<std::string>& p
953
936
default_val = unescape_string (default_val);
954
937
label = unescape_string (label);
955
938
956
- wchar_t * wlabel = 0 ;
939
+ std::wstring wlabel = narrow_to_wide (label. c_str ()) ;
957
940
958
941
if (m_use_gettext) {
959
942
if (label.length () > 1 )
960
- wlabel = wgettext (label. c_str () );
943
+ wlabel = wstrgettext (label);
961
944
else
962
- wlabel = ( wchar_t *) narrow_to_wide ( " " ). c_str () ;
945
+ wlabel = L" " ;
963
946
}
964
- else
965
- wlabel = (wchar_t *) narrow_to_wide (label.c_str ()).c_str ();
966
947
967
948
FieldSpec spec = FieldSpec (
968
949
narrow_to_wide (name.c_str ()),
@@ -1004,8 +985,6 @@ void GUIFormSpecMenu::parseTextArea(parserData* data,std::vector<std::string>& p
1004
985
Environment->addStaticText (spec.flabel .c_str (), rect, false , true , this , 0 );
1005
986
}
1006
987
}
1007
- if (m_use_gettext && (label.length () > 1 ))
1008
- delete[] wlabel;
1009
988
m_fields.push_back (spec);
1010
989
}
1011
990
@@ -1044,23 +1023,19 @@ void GUIFormSpecMenu::parseLabel(parserData* data,std::string element) {
1044
1023
1045
1024
text = unescape_string (text);
1046
1025
1047
- wchar_t * wlabel = 0 ;
1026
+ std::wstring wlabel = narrow_to_wide (text. c_str ()) ;
1048
1027
1049
1028
if (m_use_gettext)
1050
- wlabel = wgettext (text.c_str ());
1051
- else
1052
- wlabel = (wchar_t *) narrow_to_wide (text.c_str ()).c_str ();
1029
+ wlabel = wstrgettext (text);
1053
1030
1054
1031
FieldSpec spec = FieldSpec (
1055
- narrow_to_wide ( " " ) ,
1032
+ L" " ,
1056
1033
wlabel,
1057
- narrow_to_wide ( " " ) ,
1034
+ L" " ,
1058
1035
258 +m_fields.size ()
1059
1036
);
1060
1037
Environment->addStaticText (spec.flabel .c_str (), rect, false , true , this , spec.fid );
1061
1038
m_fields.push_back (spec);
1062
- if (m_use_gettext)
1063
- delete[] wlabel;
1064
1039
return ;
1065
1040
}
1066
1041
errorstream<< " Invalid label element(" << parts.size () << " ): '" << element << " '" << std::endl;
@@ -1099,9 +1074,9 @@ void GUIFormSpecMenu::parseVertLabel(parserData* data,std::string element) {
1099
1074
}
1100
1075
1101
1076
FieldSpec spec = FieldSpec (
1102
- narrow_to_wide ( " " ) ,
1077
+ L" " ,
1103
1078
narrow_to_wide (label.c_str ()),
1104
- narrow_to_wide ( " " ) ,
1079
+ L" " ,
1105
1080
258 +m_fields.size ()
1106
1081
);
1107
1082
gui::IGUIStaticText *t =
@@ -1157,12 +1132,10 @@ void GUIFormSpecMenu::parseImageButton(parserData* data,std::string element,std:
1157
1132
1158
1133
label = unescape_string (label);
1159
1134
1160
- wchar_t * wlabel = 0 ;
1135
+ std::wstring wlabel = narrow_to_wide (label. c_str ()) ;
1161
1136
1162
1137
if (m_use_gettext)
1163
- wlabel = wgettext (label.c_str ());
1164
- else
1165
- wlabel = (wchar_t *) narrow_to_wide (label.c_str ()).c_str ();
1138
+ wlabel = wstrgettext (label);
1166
1139
1167
1140
FieldSpec spec = FieldSpec (
1168
1141
narrow_to_wide (name.c_str ()),
@@ -1205,8 +1178,6 @@ void GUIFormSpecMenu::parseImageButton(parserData* data,std::string element,std:
1205
1178
e->setDrawBorder (drawborder);
1206
1179
1207
1180
m_fields.push_back (spec);
1208
- if (m_use_gettext)
1209
- delete[] wlabel;
1210
1181
return ;
1211
1182
}
1212
1183
@@ -1236,8 +1207,8 @@ void GUIFormSpecMenu::parseTabHeader(parserData* data,std::string element) {
1236
1207
1237
1208
FieldSpec spec = FieldSpec (
1238
1209
narrow_to_wide (name.c_str ()),
1239
- narrow_to_wide ( " " ) ,
1240
- narrow_to_wide ( " " ) ,
1210
+ L" " ,
1211
+ L" " ,
1241
1212
258 +m_fields.size ()
1242
1213
);
1243
1214
0 commit comments