Fixed some bugs in lobby ui
This commit is contained in:
parent
5ee6510748
commit
21cf5bca4c
23
lobby.lua
23
lobby.lua
|
@ -89,6 +89,20 @@ client_connect_ip = nil
|
|||
client_connect_port = nil
|
||||
client_connect_name = nil
|
||||
|
||||
function lobby_clear_connect_form()
|
||||
lobby_ip_textbox["sprite"]["x"] = 1000
|
||||
lobby_port_textbox["sprite"]["x"] = 1000
|
||||
lobby_name_textbox["sprite"]["x"] = 1000
|
||||
lobby_connect_message["x"] = 1000
|
||||
lobby_ip_textbox["sprite"]["y"] = 1000
|
||||
lobby_port_textbox["sprite"]["y"] = 1000
|
||||
lobby_name_textbox["sprite"]["y"] = 1000
|
||||
lobby_connect_message["y"] = 1000
|
||||
unregister_textbox(lobby_ip_textbox)
|
||||
unregister_textbox(lobby_port_textbox)
|
||||
unregister_textbox(lobby_name_textbox)
|
||||
end
|
||||
|
||||
--function lobby_client(ip, port, name, my_port)
|
||||
function lobby_client(key, ch, my_port)
|
||||
if (lobby_first_call)
|
||||
|
@ -133,7 +147,7 @@ function lobby_client(key, ch, my_port)
|
|||
end
|
||||
|
||||
-- If not already connected, connect sending info
|
||||
if (not client_connected and client_wait_for_reg_response == false and not client_filling_in_connect_form) then
|
||||
if (not client_connected and not client_wait_for_reg_response and not client_filling_in_connect_form) then
|
||||
msg_to_server = json.encode({
|
||||
{ name = client_connect_name, msg_type=OCT_LOBBY_MSG_CLIENTREG, port=my_port }
|
||||
})
|
||||
|
@ -152,8 +166,10 @@ function lobby_client(key, ch, my_port)
|
|||
OCT_LOG_INFO("Server accepted registration request!")
|
||||
lobby_connect_message["shape"] = "Connected"
|
||||
lobby_connect_message["fg"] = TB_GREEN
|
||||
client_connected = 1
|
||||
client_connected = true
|
||||
client_wait_for_reg_response = false
|
||||
client_filling_in_connect_form = false
|
||||
lobby_clear_connect_form()
|
||||
|
||||
-- Registration was unsuccessful
|
||||
elseif (client_wait_for_reg_response == true and
|
||||
|
@ -161,8 +177,9 @@ function lobby_client(key, ch, my_port)
|
|||
OCT_LOG_ERROR("Server rejected registration request, try using a different name")
|
||||
lobby_connect_message["shape"] = "Server rejected request, try changing name or port"
|
||||
lobby_connect_message["fg"] = TB_RED
|
||||
client_connected = 0
|
||||
client_connected = false
|
||||
client_wait_for_reg_response = false
|
||||
client_filling_in_connect_form = true
|
||||
|
||||
-- We received a clientlist from the server
|
||||
elseif (msg_obj["msg_type"] == OCT_LOBBY_MSG_CLIENTLIST) then
|
||||
|
|
3
ui.lua
3
ui.lua
|
@ -26,6 +26,8 @@ function create_textbox(id, pos_x, pos_y, max_length, label)
|
|||
end
|
||||
|
||||
function update_registered_textboxes_appearance()
|
||||
if (registered_textboxes[1])
|
||||
then
|
||||
-- textbox at front is focused, set to green
|
||||
registered_textboxes[1]["sprite"]["fg"] = TB_GREEN
|
||||
-- set all other textboxes to unfocused (white colored)
|
||||
|
@ -34,6 +36,7 @@ function update_registered_textboxes_appearance()
|
|||
registered_textboxes[i]["sprite"]["fg"] = TB_WHITE
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function register_textbox(textbox)
|
||||
already_registered = false;
|
||||
|
|
Loading…
Reference in New Issue