@@ -62,6 +62,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
62
62
return ; \
63
63
}
64
64
65
+ extern gui::IGUIEnvironment* guienv;
65
66
66
67
/*
67
68
GUIFormSpecMenu
@@ -85,7 +86,8 @@ GUIFormSpecMenu::GUIFormSpecMenu(irr::IrrlichtDevice* dev,
85
86
m_lock(false ),
86
87
m_form_src(fsrc),
87
88
m_text_dst(tdst),
88
- m_ext_ptr(ext_ptr)
89
+ m_ext_ptr(ext_ptr),
90
+ m_font(guienv->getSkin ()->getFont())
89
91
{
90
92
current_keys_pending.key_down = false ;
91
93
current_keys_pending.key_up = false ;
@@ -388,15 +390,18 @@ void GUIFormSpecMenu::parseCheckbox(parserData* data,std::string element)
388
390
pos.X += stof (v_pos[0 ]) * (float ) spacing.X ;
389
391
pos.Y += stof (v_pos[1 ]) * (float ) spacing.Y ;
390
392
391
- core::rect<s32> rect = core::rect<s32>(pos.X , pos.Y +((imgsize.Y /2 )-15 ), pos.X +300 , pos.Y +((imgsize.Y /2 )+15 ));
392
-
393
393
bool fselected = false ;
394
394
395
395
if (selected == " true" )
396
396
fselected = true ;
397
397
398
398
std::wstring wlabel = narrow_to_wide (label.c_str ());
399
399
400
+ core::rect<s32> rect = core::rect<s32>(
401
+ pos.X , pos.Y + ((imgsize.Y /2 ) - 15 ),
402
+ pos.X + m_font->getDimension (wlabel.c_str ()).Width + 25 , // text size + size of checkbox
403
+ pos.Y + ((imgsize.Y /2 ) + 15 ));
404
+
400
405
FieldSpec spec (
401
406
narrow_to_wide (name.c_str ()),
402
407
wlabel, // Needed for displaying text on MSVC
@@ -1083,15 +1088,18 @@ void GUIFormSpecMenu::parseLabel(parserData* data,std::string element)
1083
1088
pos.X += stof (v_pos[0 ]) * (float )spacing.X ;
1084
1089
pos.Y += stof (v_pos[1 ]) * (float )spacing.Y ;
1085
1090
1086
- core::rect<s32> rect = core::rect<s32>(pos.X , pos.Y +((imgsize.Y /2 )-15 ), pos.X +300 , pos.Y +((imgsize.Y /2 )+15 ));
1087
-
1088
1091
if (data->bp_set != 2 )
1089
1092
errorstream<<" WARNING: invalid use of label without a size[] element" <<std::endl;
1090
1093
1091
1094
text = unescape_string (text);
1092
1095
1093
1096
std::wstring wlabel = narrow_to_wide (text.c_str ());
1094
1097
1098
+ core::rect<s32> rect = core::rect<s32>(
1099
+ pos.X , pos.Y +((imgsize.Y /2 )-15 ),
1100
+ pos.X + m_font->getDimension (wlabel.c_str ()).Width ,
1101
+ pos.Y +((imgsize.Y /2 )+15 ));
1102
+
1095
1103
FieldSpec spec (
1096
1104
L" " ,
1097
1105
wlabel,
@@ -1119,7 +1127,13 @@ void GUIFormSpecMenu::parseVertLabel(parserData* data,std::string element)
1119
1127
pos.X += stof (v_pos[0 ]) * (float )spacing.X ;
1120
1128
pos.Y += stof (v_pos[1 ]) * (float )spacing.Y ;
1121
1129
1122
- core::rect<s32> rect = core::rect<s32>(pos.X , pos.Y +((imgsize.Y /2 )-15 ), pos.X +15 , pos.Y +300 );
1130
+ core::rect<s32> rect = core::rect<s32>(
1131
+ pos.X , pos.Y +((imgsize.Y /2 )-15 ),
1132
+ pos.X +15 , pos.Y +
1133
+ (m_font->getKerningHeight () +
1134
+ m_font->getDimension (text.c_str ()).Height )
1135
+ * (text.length ()+1 ));
1136
+ // actually text.length() would be correct but adding +1 avoids to break all mods
1123
1137
1124
1138
if (data->bp_set != 2 )
1125
1139
errorstream<<" WARNING: invalid use of label without a size[] element" <<std::endl;
0 commit comments