function p.on_start(wid)
    -- ga_print("xar main menu start")

    local min_y = 0.15
    local max_y = 0.75
    local char_w = 0.03
    local char_h = 0.06
    local col = {x=0.0, y=0.5, z=0.5}
    local options = {}
    if( ga_genesis() ) then
        options = {
            "CONTROLS",
            "RESPAWN",
            "VIDEO + SOUND",
            "GAME" }
    else
        options = {
            "CONTROLS",
            "RESPAWN",
            "DIFFICULTY",
            "VIDEO + SOUND",
            "GAME" }
    end
    -- ga_print("about to call ga_win_widget_small_list_start")
    ga_win_widget_small_list_start(
        wid, min_y, max_y, char_w, char_h,
        col, options)

    -- ga_print("xar main menu end")
end

function p.on_end(wid)
    --Nothing to do.
end

function p.render(wid)
    ga_win_set_background(wid, std.vec(0.0, 0.0, 0.0), 0.95)

    ga_win_set_char_size(wid, 0.04, 0.08)
    ga_win_txt_center(wid, 0.85, "XAR MAIN MENU")

    ga_win_set_char_size(wid, 0.02, 0.04)
    ga_win_txt_center(wid, 0.06, "Go Back (ESC)")
end

function p.process_input(wid)
    local sel = ga_win_widget_small_list_process_input(wid)
    local sel_str = ga_win_widget_small_list_get_entry(wid, sel)
    if( sel_str == "CONTROLS" ) then
        ga_main_menu_push("win_main_menu_controls")
        return
    end
    if( sel_str == "RESPAWN" ) then
        ga_main_menu_push("win_main_menu_respawn")
        return
    end
    if( sel_str == "DIFFICULTY" ) then
        ga_main_menu_push("win_main_menu_diff")
        return
    end
        if( sel_str == "VIDEO + SOUND" ) then
        ga_main_menu_push("win_main_menu_video_sound")
        return
    end
    -- if( sel_str == "CAMERA" ) then
    --     --I may want to change the name later.
    --     ga_main_menu_push("win_main_menu_camera")
    --     return
    -- end
    -- if( sel_str == "HUD" ) then
    --     ga_main_menu_push("win_main_menu_hud")
    -- end
    -- if( sel_str == "SOUND" ) then
    --     ga_main_menu_push("win_main_menu_sound")
    --     return
    -- end
    if( sel_str == "GAME" ) then
        ga_main_menu_push("win_main_menu_game")
        return
    end

    if ga_win_key_pressed(wid, "ESC") then
        local return_to_game = false
        ga_main_menu_pop_all(return_to_game)
        return
    end

    if( not ga_get_sys_b("menu.in_main") ) then
        --Maybe going to another game window.
        local return_to_game = true
        if ga_win_key_pressed(wid, "F2") then
            ga_main_menu_pop_all(return_to_game)
            ga_window_push("win_stats2")
            return
        end
        if ga_win_key_pressed(wid, "F3") then
            ga_main_menu_pop_all(return_to_game)
            ga_window_push("win_stats3")
            return
        end
        if ga_win_key_pressed(wid, "F4") then
            ga_main_menu_pop_all(return_to_game)
            ga_window_push("win_stats4")
            return
        end
        if ga_win_key_pressed(wid, "F5") then
            ga_main_menu_pop_all(return_to_game)
            ga_window_push("win_stats5")
            return
        end
        if ga_win_key_pressed(wid, "F6") then
            ga_main_menu_pop_all(return_to_game)
            ga_window_push("win_stats6")
            return
        end
        if ga_win_key_pressed(wid, "F7") then
            ga_main_menu_pop_all(return_to_game)
            ga_window_push("win_stats7")
            return
        end
    end
end
