108
108
GUI_ID_ENABLE_PARTICLES_CB,
109
109
GUI_ID_DAMAGE_CB,
110
110
GUI_ID_CREATIVE_CB,
111
+ GUI_ID_PUBLIC_CB,
111
112
GUI_ID_JOIN_GAME_BUTTON,
112
113
GUI_ID_CHANGE_KEYS_BUTTON,
113
114
GUI_ID_DELETE_WORLD_BUTTON,
@@ -562,6 +563,14 @@ void GUIMainMenu::regenerateGui(v2u32 screensize)
562
563
Environment->addCheckBox (m_data->enable_damage , rect, this , GUI_ID_DAMAGE_CB,
563
564
wgettext (" Enable Damage" ));
564
565
}
566
+ #if USE_CURL
567
+ {
568
+ core::rect<s32> rect (0 , 0 , 250 , 30 );
569
+ rect += m_topleft_server + v2s32 (30 +20 +250 +20 , 60 );
570
+ Environment->addCheckBox (m_data->enable_public , rect, this , GUI_ID_PUBLIC_CB,
571
+ wgettext (" Public" ));
572
+ }
573
+ #endif
565
574
// Delete world button
566
575
{
567
576
core::rect<s32> rect (0 , 0 , 130 , 30 );
@@ -841,6 +850,11 @@ void GUIMainMenu::readInput(MainMenuData *dst)
841
850
if (e != NULL && e->getType () == gui::EGUIET_CHECK_BOX)
842
851
dst->enable_damage = ((gui::IGUICheckBox*)e)->isChecked ();
843
852
}
853
+ {
854
+ gui::IGUIElement *e = getElementFromId (GUI_ID_PUBLIC_CB);
855
+ if (e != NULL && e->getType () == gui::EGUIET_CHECK_BOX)
856
+ dst->enable_public = ((gui::IGUICheckBox*)e)->isChecked ();
857
+ }
844
858
{
845
859
gui::IGUIElement *e = getElementFromId (GUI_ID_FANCYTREE_CB);
846
860
if (e != NULL && e->getType () == gui::EGUIET_CHECK_BOX)
@@ -912,8 +926,8 @@ void GUIMainMenu::readInput(MainMenuData *dst)
912
926
{
913
927
ServerListSpec server =
914
928
getServerListSpec (wide_to_narrow (dst->address ), wide_to_narrow (dst->port ));
915
- dst->servername = server. name ;
916
- dst->serverdescription = server. description ;
929
+ dst->servername = server[ " name" ]. asString () ;
930
+ dst->serverdescription = server[ " description" ]. asString () ;
917
931
}
918
932
}
919
933
@@ -1174,13 +1188,31 @@ void GUIMainMenu::updateGuiServerList()
1174
1188
i != m_data->servers .end (); i++)
1175
1189
{
1176
1190
std::string text;
1177
- if (i->name != " " && i->description != " " )
1178
- text = i->name + " (" + i->description + " )" ;
1179
- else if (i->name !=" " )
1180
- text = i->name ;
1181
- else
1182
- text = i->address + " :" + i->port ;
1183
1191
1192
+ if ((*i)[" clients" ].asString ().size ())
1193
+ text += (*i)[" clients" ].asString ();
1194
+ if ((*i)[" clients_max" ].asString ().size ())
1195
+ text += " /" + (*i)[" clients_max" ].asString ();
1196
+ text += " " ;
1197
+ if ((*i)[" version" ].asString ().size ())
1198
+ text += (*i)[" version" ].asString () + " " ;
1199
+ if ((*i)[" password" ].asString ().size ())
1200
+ text += " *" ;
1201
+ if ((*i)[" creative" ].asString ().size ())
1202
+ text += " C" ;
1203
+ if ((*i)[" damage" ].asString ().size ())
1204
+ text += " D" ;
1205
+ if ((*i)[" pvp" ].asString ().size ())
1206
+ text += " P" ;
1207
+ text += " " ;
1208
+
1209
+ if ((*i)[" name" ] != " " && (*i)[" description" ] != " " )
1210
+ text += (*i)[" name" ].asString () + " (" + (*i)[" description" ].asString () + " )" ;
1211
+ else if ((*i)[" name" ] !=" " )
1212
+ text += (*i)[" name" ].asString ();
1213
+ else
1214
+ text += (*i)[" address" ].asString () + " :" + (*i)[" port" ].asString ();
1215
+
1184
1216
serverlist->addItem (narrow_to_wide (text).c_str ());
1185
1217
}
1186
1218
}
@@ -1191,26 +1223,26 @@ void GUIMainMenu::serverListOnSelected()
1191
1223
{
1192
1224
gui::IGUIListBox *serverlist = (gui::IGUIListBox*)getElementFromId (GUI_ID_SERVERLIST);
1193
1225
u16 id = serverlist->getSelected ();
1194
- if (id < 0 ) return ;
1226
+ // if (id < 0) return; // u16>0!
1195
1227
((gui::IGUIEditBox*)getElementFromId (GUI_ID_ADDRESS_INPUT))
1196
- ->setText (narrow_to_wide (m_data->servers [id]. address ).c_str ());
1228
+ ->setText (narrow_to_wide (m_data->servers [id][ " address" ]. asString () ).c_str ());
1197
1229
((gui::IGUIEditBox*)getElementFromId (GUI_ID_PORT_INPUT))
1198
- ->setText (narrow_to_wide (m_data->servers [id]. port ).c_str ());
1230
+ ->setText (narrow_to_wide (m_data->servers [id][ " port" ]. asString () ).c_str ());
1199
1231
}
1200
1232
}
1201
1233
1202
1234
ServerListSpec GUIMainMenu::getServerListSpec (std::string address, std::string port)
1203
1235
{
1204
1236
ServerListSpec server;
1205
- server. address = address;
1206
- server. port = port;
1237
+ server[ " address" ] = address;
1238
+ server[ " port" ] = port;
1207
1239
for (std::vector<ServerListSpec>::iterator i = m_data->servers .begin ();
1208
1240
i != m_data->servers .end (); i++)
1209
1241
{
1210
- if (i-> address == address && i-> port == port)
1242
+ if ((*i)[ " address" ] == address && (*i)[ " port" ] == port)
1211
1243
{
1212
- server. description = i-> description ;
1213
- server. name = i-> name ;
1244
+ server[ " description" ] = (*i)[ " description" ] ;
1245
+ server[ " name" ] = (*i)[ " name" ] ;
1214
1246
break ;
1215
1247
}
1216
1248
}
0 commit comments