mirror of
https://github.com/minetest/minetest.git
synced 2024-12-23 14:42:24 +01:00
Fix serverlist
This commit is contained in:
parent
e3b7c8e0cc
commit
1c7c5d571d
@ -15,7 +15,7 @@ function render_favourite(spec)
|
|||||||
local text = ""
|
local text = ""
|
||||||
|
|
||||||
if spec.name ~= nil then
|
if spec.name ~= nil then
|
||||||
text = text .. spec.name:trim()
|
text = text .. fs_escape_string(spec.name:trim())
|
||||||
|
|
||||||
if spec.description ~= nil then
|
if spec.description ~= nil then
|
||||||
--TODO make sure there's no invalid chat in spec.description
|
--TODO make sure there's no invalid chat in spec.description
|
||||||
@ -52,12 +52,6 @@ function render_favourite(spec)
|
|||||||
details = details .. " "
|
details = details .. " "
|
||||||
end
|
end
|
||||||
|
|
||||||
if spec.port ~= nil then
|
|
||||||
text = text .. ":" .. spec.port:trim()
|
|
||||||
else
|
|
||||||
text = text .. ":??"
|
|
||||||
end
|
|
||||||
|
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -119,6 +113,8 @@ function cleanup_path(temppath)
|
|||||||
return temppath
|
return temppath
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
function menu.set_texture(identifier,gamedetails)
|
function menu.set_texture(identifier,gamedetails)
|
||||||
local texture_set = false
|
local texture_set = false
|
||||||
if menu.texturepack ~= nil and gamedetails ~= nil then
|
if menu.texturepack ~= nil and gamedetails ~= nil then
|
||||||
@ -696,6 +692,11 @@ function tabbuilder.handle_multiplayer_buttons(fields)
|
|||||||
end
|
end
|
||||||
gamedata.selected_world = 0
|
gamedata.selected_world = 0
|
||||||
|
|
||||||
|
if menu.favorites ~= nil then
|
||||||
|
gamedata.servername = menu.favorites[event.index].name
|
||||||
|
gamedata.serverdescription = menu.favorites[event.index].description
|
||||||
|
end
|
||||||
|
|
||||||
if gamedata.address ~= nil and
|
if gamedata.address ~= nil and
|
||||||
gamedata.port ~= nil then
|
gamedata.port ~= nil then
|
||||||
|
|
||||||
@ -704,10 +705,7 @@ function tabbuilder.handle_multiplayer_buttons(fields)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if event.typ == "CHG" then
|
if event.typ == "CHG" then
|
||||||
local address = menu.favorites[event.index].name
|
local address = menu.favorites[event.index].address
|
||||||
if address == nil then
|
|
||||||
address = menu.favorites[event.index].address
|
|
||||||
end
|
|
||||||
local port = menu.favorites[event.index].port
|
local port = menu.favorites[event.index].port
|
||||||
|
|
||||||
if address ~= nil and
|
if address ~= nil and
|
||||||
@ -757,7 +755,7 @@ function tabbuilder.handle_multiplayer_buttons(fields)
|
|||||||
else
|
else
|
||||||
menu.favorites = engine.get_favorites("local")
|
menu.favorites = engine.get_favorites("local")
|
||||||
end
|
end
|
||||||
|
menu.fav_selected = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -765,6 +763,7 @@ function tabbuilder.handle_multiplayer_buttons(fields)
|
|||||||
local current_favourite = engine.get_textlist_index("favourites")
|
local current_favourite = engine.get_textlist_index("favourites")
|
||||||
engine.delete_favorite(current_favourite)
|
engine.delete_favorite(current_favourite)
|
||||||
menu.favorites = engine.get_favorites()
|
menu.favorites = engine.get_favorites()
|
||||||
|
menu.fav_selected = nil
|
||||||
|
|
||||||
engine.setting_set("address","")
|
engine.setting_set("address","")
|
||||||
engine.setting_get("port","")
|
engine.setting_get("port","")
|
||||||
@ -779,6 +778,20 @@ function tabbuilder.handle_multiplayer_buttons(fields)
|
|||||||
gamedata.password = fields["te_pwd"]
|
gamedata.password = fields["te_pwd"]
|
||||||
gamedata.address = fields["te_address"]
|
gamedata.address = fields["te_address"]
|
||||||
gamedata.port = fields["te_port"]
|
gamedata.port = fields["te_port"]
|
||||||
|
|
||||||
|
local fav_idx = engine.get_textlist_index("favourites")
|
||||||
|
|
||||||
|
if fav_idx > 0 and fav_idx <= #menu.favorites and
|
||||||
|
menu.favorites[fav_idx].address == fields["te_address"] and
|
||||||
|
menu.favorites[fav_idx].port == fields["te_port"] then
|
||||||
|
|
||||||
|
gamedata.servername = menu.favorites[fav_idx].name
|
||||||
|
gamedata.serverdescription = menu.favorites[fav_idx].description
|
||||||
|
else
|
||||||
|
gamedata.servername = ""
|
||||||
|
gamedata.serverdescription = ""
|
||||||
|
end
|
||||||
|
|
||||||
gamedata.selected_world = 0
|
gamedata.selected_world = 0
|
||||||
|
|
||||||
engine.start()
|
engine.start()
|
||||||
@ -1134,12 +1147,18 @@ function tabbuilder.tab_multiplayer()
|
|||||||
"label[9,0;Name/Password]" ..
|
"label[9,0;Name/Password]" ..
|
||||||
"field[1.25,5.25;5.5,0.5;te_address;;" ..engine.setting_get("address") .."]" ..
|
"field[1.25,5.25;5.5,0.5;te_address;;" ..engine.setting_get("address") .."]" ..
|
||||||
"field[6.75,5.25;2.25,0.5;te_port;;" ..engine.setting_get("port") .."]" ..
|
"field[6.75,5.25;2.25,0.5;te_port;;" ..engine.setting_get("port") .."]" ..
|
||||||
"button[6.45,3.95;2.25,0.5;btn_delete_favorite;Delete]" ..
|
"checkbox[1,3.6;cb_public_serverlist;Public Serverlist;" ..
|
||||||
|
dump(engine.setting_getbool("public_serverlist")) .. "]"
|
||||||
|
|
||||||
|
if not engine.setting_getbool("public_serverlist") then
|
||||||
|
retval = retval ..
|
||||||
|
"button[6.45,3.95;2.25,0.5;btn_delete_favorite;Delete]"
|
||||||
|
end
|
||||||
|
|
||||||
|
retval = retval ..
|
||||||
"button[9,4.95;2.5,0.5;btn_mp_connect;Connect]" ..
|
"button[9,4.95;2.5,0.5;btn_mp_connect;Connect]" ..
|
||||||
"field[9.25,1;2.5,0.5;te_name;;" ..engine.setting_get("name") .."]" ..
|
"field[9.25,1;2.5,0.5;te_name;;" ..engine.setting_get("name") .."]" ..
|
||||||
"pwdfield[9.25,1.75;2.5,0.5;te_pwd;]" ..
|
"pwdfield[9.25,1.75;2.5,0.5;te_pwd;]" ..
|
||||||
"checkbox[1,3.6;cb_public_serverlist;Public Serverlist;" ..
|
|
||||||
dump(engine.setting_getbool("public_serverlist")) .. "]" ..
|
|
||||||
"textlist[1,0.35;7.5,3.35;favourites;"
|
"textlist[1,0.35;7.5,3.35;favourites;"
|
||||||
|
|
||||||
if #menu.favorites > 0 then
|
if #menu.favorites > 0 then
|
||||||
@ -1150,7 +1169,6 @@ function tabbuilder.tab_multiplayer()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
print("cfav: " .. dump(menu.fav_selected))
|
|
||||||
if menu.fav_selected ~= nil then
|
if menu.fav_selected ~= nil then
|
||||||
retval = retval .. ";" .. menu.fav_selected .. "]"
|
retval = retval .. ";" .. menu.fav_selected .. "]"
|
||||||
else
|
else
|
||||||
@ -1195,9 +1213,10 @@ function tabbuilder.tab_server()
|
|||||||
retval = retval .. "," .. menu.worldlist[i].name ..
|
retval = retval .. "," .. menu.worldlist[i].name ..
|
||||||
" \\[" .. menu.worldlist[i].gameid .. "\\]"
|
" \\[" .. menu.worldlist[i].gameid .. "\\]"
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
retval = retval .. ";" .. index .. "]"
|
retval = retval .. ";" .. index .. "]"
|
||||||
|
else
|
||||||
|
retval = retval .. ";0]"
|
||||||
|
end
|
||||||
|
|
||||||
return retval
|
return retval
|
||||||
end
|
end
|
||||||
@ -1227,7 +1246,8 @@ end
|
|||||||
function tabbuilder.tab_singleplayer()
|
function tabbuilder.tab_singleplayer()
|
||||||
local index = engine.setting_get("main_menu_singleplayer_world_idx")
|
local index = engine.setting_get("main_menu_singleplayer_world_idx")
|
||||||
|
|
||||||
if index == nil then
|
if index == nil or
|
||||||
|
#menu.filtered_game_list_raw() == 0 then
|
||||||
index = 0
|
index = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -77,9 +77,11 @@ function fs_escape_string(text)
|
|||||||
text = newtext
|
text = newtext
|
||||||
end
|
end
|
||||||
|
|
||||||
text = text:gsub("%[","\\%[")
|
text = string.gsub(text,"\\","\\\\")
|
||||||
text = text:gsub("]","\\]")
|
text = string.gsub(text,"%]","\\]")
|
||||||
text = text:gsub(";","\\;")
|
text = string.gsub(text,"%[","\\[")
|
||||||
|
text = string.gsub(text,";","\\;")
|
||||||
|
text = string.gsub(text,",","\\,")
|
||||||
end
|
end
|
||||||
return text
|
return text
|
||||||
end
|
end
|
||||||
|
@ -611,7 +611,7 @@ void GUIFormSpecMenu::parseTextList(parserData* data,std::string element) {
|
|||||||
std::vector<std::string> v_pos = split(parts[0],',');
|
std::vector<std::string> v_pos = split(parts[0],',');
|
||||||
std::vector<std::string> v_geom = split(parts[1],',');
|
std::vector<std::string> v_geom = split(parts[1],',');
|
||||||
std::string name = parts[2];
|
std::string name = parts[2];
|
||||||
std::vector<std::string> items = split(parts[3],',');
|
std::vector<std::string> items = split(parts[3],',',true);
|
||||||
std::string str_initial_selection = "";
|
std::string str_initial_selection = "";
|
||||||
std::string str_transparent = "false";
|
std::string str_transparent = "false";
|
||||||
|
|
||||||
@ -1352,6 +1352,7 @@ void GUIFormSpecMenu::parseBox(parserData* data,std::string element) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GUIFormSpecMenu::parseElement(parserData* data,std::string element) {
|
void GUIFormSpecMenu::parseElement(parserData* data,std::string element) {
|
||||||
|
|
||||||
//some prechecks
|
//some prechecks
|
||||||
if (element == "")
|
if (element == "")
|
||||||
return;
|
return;
|
||||||
|
@ -203,6 +203,8 @@ int guiLuaApi::l_start(lua_State *L)
|
|||||||
engine->m_data->password = getTextData(L,"password");
|
engine->m_data->password = getTextData(L,"password");
|
||||||
engine->m_data->address = getTextData(L,"address");
|
engine->m_data->address = getTextData(L,"address");
|
||||||
engine->m_data->port = getTextData(L,"port");
|
engine->m_data->port = getTextData(L,"port");
|
||||||
|
engine->m_data->serverdescription = getTextData(L,"serverdescription");
|
||||||
|
engine->m_data->servername = getTextData(L,"servername");
|
||||||
|
|
||||||
//close menu next time
|
//close menu next time
|
||||||
engine->m_startgame = true;
|
engine->m_startgame = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user