
server_connect_box {
    width = 270,
    height = 220,
    background_color = rgba(0, 0, 0, 0.3),
    shadow = shadow(0.0, 0.0, rgba(0, 0, 0, 0.6), 10.0, 3.0, "outset"),
    layout = "grid",
    rows = 3,
    spacing = 20,
    margin = 10,
}

server_connect_error {
    clip_overflow = true,
}
server_connect_error(show=true) {
    width = 270,
    layout = "lined",
    line_height = 30,
    x = (parent_width / 2) - (270 / 2),
    y = (parent_height / 2) + 160,
    background_color = rgba(120, 0, 0, 0.6),
    shadow = shadow(0.0, 0.0, rgba(120, 0, 0, 1.0), 10.0, 3.0, "outset"),
}
server_connect_error(show=true, lobby_list=true) {
    clip_overflow = true,
    y = (parent_height / 2) + 300,
    x = (parent_width / 2) - (600 / 2),
    width = 600,
}

server_connect_error(show=true) > @text {
    font_size = 25,
    font_color = rgb(255, 255, 255),
}

server_connect_box > center > label {
    layout = "lined",
    line_height = 40,
}

server_connect_box > center > label > @text {
    font_size = 35,
    font_color = rgb(255, 255, 255),
}

connecting_message {
    width = 0,
    height = 0,

    on_init = "init#
        local message = 'Connecting..'
        local chars = {}

        local len = #message;
        for i = 1, len do
            local char = ui.new_text(message:sub(i, i))
            char:set_property_int('x', -(len / 2) * 20 + i * 20);
            char:set_property_int('y', 0);
            node:add_child(char)
        end
        node:set_property_float('$time', -math.pi)
    ",
    on_update = "init#
        local message = 'Connecting..'
        local len = #message;

        local time = node:get_property_float('$time')
        time = (time + evt.delta * 0.1) % (math.pi * (len + 5) * 0.5);
        node:set_property_float('$time', time)
        local i = 1
        for char in node:query():text():matches() do
            local base_time = math.pi * i * 0.5
            if time >= base_time and time - base_time <= math.pi then
                char:set_property_int('y', -25 * math.sin(time - base_time))
            else
                char:set_property_int('y', 0)
            end
            i = i + 1
        end
    ",
}

connecting_message > @text(x=x, y=y) {
    x = x,
    y = y,
    width = 20,
    height = 40,
}

connecting_message > @text {
    font_size = 32,
    font_color = rgb(255, 255, 255),
}