main_menu_pivot = nil

game_opening_pivot = nil

open1 = nil
open2 = nil
open3 = nil
open4 = nil
open5 = nil
open6 = nil

open1_text1 = nil
open1_text2 = nil
open2_text1 = nil
open2_text2 = nil
open3_text1 = nil
open4_text = nil
open5_text1 = nil
open5_text2 = nil
open5_text3 = nil
open5_text4 = nil
open5_text5 = nil
open5_text6 = nil
open6_text1 = nil
open6_text2 = nil
press_enter = nil

time_accumulator = 0

load_game_num = nil

electro_splash = nil
navi_splash = nil
menu_img = nil

text_fill = nil
text_line = nil
text_fill_game_opening = nil
text_line_game_opening = nil
text_select = nil

title = nil
new_game_txt = nil
load_game_txt = nil
exit_game_txt = nil

show_load_menu = nil
selected_index = nil
load_index = nil
file_exist = { }

intro_music = E.load_sound(media_dir .. "mozart_night.ogg")
menu_click = E.load_sound(media_dir .. "menu_click.ogg")
menu_swap = E.load_sound(media_dir .. "menu_swap.ogg")
menu_music = E.load_sound(media_dir .. "fireside.ogg")
menu_music_playing = false

time_accumulator = 0

function highlight_item(index)
    if index == 0 then
        E.set_string_fill(E.get_entity_child(new_game_txt, 0), text_select)
        E.set_string_fill(E.get_entity_child(load_game_txt, 0), text_fill)
        E.set_string_fill(E.get_entity_child(exit_game_txt, 0), text_fill)
    elseif index == 1 then
        E.set_string_fill(E.get_entity_child(new_game_txt, 0), text_fill)
        E.set_string_fill(E.get_entity_child(load_game_txt, 0), text_select)
        E.set_string_fill(E.get_entity_child(exit_game_txt, 0), text_fill)
    else
        E.set_string_fill(E.get_entity_child(new_game_txt, 0), text_fill)
        E.set_string_fill(E.get_entity_child(load_game_txt, 0), text_fill)
        E.set_string_fill(E.get_entity_child(exit_game_txt, 0), text_select)
    end
end

function show_load_screen(show)
    E.set_entity_flags(title, E.entity_flag_hidden, (show))
    E.set_entity_flags(new_game_txt, E.entity_flag_hidden, (show))
    E.set_entity_flags(load_game_txt, E.entity_flag_hidden, (show))
    E.set_entity_flags(exit_game_txt, E.entity_flag_hidden, (show))
    E.set_entity_flags(load_game_txt2, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state1, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state2, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state3, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state4, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state5, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state6, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state7, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state8, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state9, E.entity_flag_hidden, (not show))
    E.set_entity_flags(game_state0, E.entity_flag_hidden, (not show))
    E.set_entity_flags(go_back, E.entity_flag_hidden, (not show))
end

function text_fill_color(color)
    if color then
        return text_fill
    else
        return text_empty
    end
end

function load_menu_move(move)
    local temp = load_index
    local i = load_index + move
    if(i > 10) then
        return temp
    end
    if(i < 0) then
        return temp
    end
    while (not file_exist[i]) do
        i = i + move
        if(i > 10) then
                return temp
        end
        if(i < 0) then
                return temp
        end
    end
    E.play_sound(menu_swap)
    return i
end

function highlight_load_menu(index)
    E.set_string_fill(E.get_entity_child(game_state1, 0), text_fill_color(file_exist[1]))
    E.set_string_fill(E.get_entity_child(game_state2, 0), text_fill_color(file_exist[2]))
    E.set_string_fill(E.get_entity_child(game_state3, 0), text_fill_color(file_exist[3]))
    E.set_string_fill(E.get_entity_child(game_state4, 0), text_fill_color(file_exist[4]))
    E.set_string_fill(E.get_entity_child(game_state5, 0), text_fill_color(file_exist[5]))
    E.set_string_fill(E.get_entity_child(game_state6, 0), text_fill_color(file_exist[6]))
    E.set_string_fill(E.get_entity_child(game_state7, 0), text_fill_color(file_exist[7]))
    E.set_string_fill(E.get_entity_child(game_state8, 0), text_fill_color(file_exist[8]))
    E.set_string_fill(E.get_entity_child(game_state9, 0), text_fill_color(file_exist[9]))
    E.set_string_fill(E.get_entity_child(game_state0, 0), text_fill_color(file_exist[0]))
    E.set_string_fill(E.get_entity_child(go_back, 0), text_fill)
    if index == 1 then
        E.set_string_fill(E.get_entity_child(game_state1, 0), text_select)
    elseif index == 2 then
        E.set_string_fill(E.get_entity_child(game_state2, 0), text_select)
    elseif index == 3 then
        E.set_string_fill(E.get_entity_child(game_state3, 0), text_select)
    elseif index == 4 then
        E.set_string_fill(E.get_entity_child(game_state4, 0), text_select)
    elseif index == 5 then
        E.set_string_fill(E.get_entity_child(game_state5, 0), text_select)
    elseif index == 6 then
        E.set_string_fill(E.get_entity_child(game_state6, 0), text_select)
    elseif index == 7 then
        E.set_string_fill(E.get_entity_child(game_state7, 0), text_select)
    elseif index == 8 then
        E.set_string_fill(E.get_entity_child(game_state8, 0), text_select)
    elseif index == 9 then
        E.set_string_fill(E.get_entity_child(game_state9, 0), text_select)
    elseif index == 0 then
        E.set_string_fill(E.get_entity_child(game_state0, 0), text_select)
    else
        E.set_string_fill(E.get_entity_child(go_back, 0), text_select)
    end
end

function destroy_main_menu()
	E.delete_entity(main_menu_pivot)
	E.free_sound(menu_swap)
	E.free_sound(menu_music)
	
	E.set_entity_flags(game_opening_pivot, E.entity_flag_hidden, false)
	
	E.loop_sound(intro_music)
	time_accumulator = 0
end

function destroy_game_opening()
	E.free_sound(menu_click)
	E.delete_entity(game_opening_pivot)
	--E.free_sound(intro_music)
end

local function centered_string_game_opening(text, line, fill)
        local string = E.create_string(text)
        local pivot = E.create_pivot()
        
        --local x0, y0, z0, x1, y1, z1 = E.get_entity_bound(string)
        
        E.set_string_line(string, line)
        E.set_string_fill(string, fill)
        E.parent_entity(string, pivot)
        
        --E.set_entity_position(string, -(x1 - x0)/2, -0.5, 0)
        E.set_entity_position(string, 0, -0.5, viewport.depth_bisect-1)
        
        return pivot, viewport.width, viewport.height--(x1 - x0), (y1 - y0)
end

local function centered_string_main_menu(text, line, fill)
        local string = E.create_string(text)
        local pivot = E.create_pivot()
        
        local x0, y0, z0, x1, y1, z1 = E.get_entity_bound(string)
        
        E.set_string_line(string, line)
        E.set_string_fill(string, fill)
        E.parent_entity(string, pivot)
        
        E.set_entity_position(string, -(x1 - x0)/2, -0.5, 0)
        
        return pivot, (x1 - x0), (y1 - y0)
end

local function init_main_menu()
	game_state = main_menu
	
    --camera = E.create_camera(E.camera_type_perspective)
    main_menu_pivot = E.create_pivot()

    local images = E.create_pivot()
    local text = E.create_pivot()
	
	E.parent_entity(main_menu_pivot, camera)
    E.parent_entity(images, main_menu_pivot )
    E.parent_entity(text, images )

    E.set_background(0.0, 0.0, 0.0)

    electro_splash = make_opaque_image_billboard(media_dir .. "electro.jpg")
    E.set_entity_alpha(electro_splash, 0.0) -- hidden
    fit_to_view(electro_splash, 0.5, 0.3, 0, 0)
    E.parent_entity(electro_splash, images)

    navi_splash = make_opaque_image_billboard(media_dir .. "splash.jpg")
    E.set_entity_alpha(navi_splash, 0.0) -- hidden
    fit_to_view(navi_splash, 0.7, 0.3, 0, 0)
    E.parent_entity(navi_splash, images)

    menu_img = make_opaque_image_billboard(media_dir .. "close1.jpg")
    E.set_entity_alpha(menu_img, 0.0) -- hidden
    fit_to_view(menu_img, 0.7, 0.7, 0, 0)
    E.parent_entity(menu_img, images)

    --E.set_typeface(media_dir .. "VeraBd.ttf", 0.001, 0.03)
    E.set_typeface(media_dir .. "Nou.ttf", 0.001, 0.03)
    --E.set_typeface(media_dir .. "pala.ttf", 0.001, 0.03)

    text_fill = E.create_brush()
    E.set_brush_color(text_fill, 0.696875, 0.0, 0.02890625, 0.2)
    E.set_brush_flags(text_fill, E.brush_flag_unlit, true)

    text_line = E.create_brush()
    E.set_brush_color(text_line, 0.696875, 0.0, 0.02890625, 0.5)
    E.set_brush_flags(text_line, E.brush_flag_unlit, true)

    text_select = E.create_brush()
    E.set_brush_color(text_select, 0.696875, 0.0, 0.02890625, 1.0)
    E.set_brush_flags(text_select, E.brush_flag_unlit, true)
    
    text_empty = E.create_brush()
    E.set_brush_color(text_empty, 0.1, 0.1, 0.1, 1.0)
    E.set_brush_flags(text_empty, E.brush_flag_unlit, true)

    title, w, h = centered_string_main_menu("Art Thief", text_select, text_select)
    E.set_entity_alpha(title, 0.0) -- hidden
    --E.set_entity_scale(title, 0.125, 0.125, 1)
    E.set_entity_scale(title, 0.25, 0.25, 1)
    E.set_entity_position(title, 0, h/2, viewport.depth_bisect-1)
    E.parent_entity(title, text)

    new_game_txt, w, h = centered_string_main_menu("New Game", text_line, text_select)
    E.set_entity_alpha(new_game_txt, 0.0) -- hidden
    E.set_entity_scale(new_game_txt, 0.095, 0.095, 1)
    E.set_entity_position(new_game_txt, 0, 0, viewport.depth_bisect-1)
    E.parent_entity(new_game_txt, text)

    load_game_txt, w, h = centered_string_main_menu("Load Game", text_line, text_fill)
    E.set_entity_alpha(load_game_txt, 0.0) -- hidden
    E.set_entity_scale(load_game_txt, 0.095, 0.095, 1)
    E.set_entity_position(load_game_txt, 0, -0.1, viewport.depth_bisect-1)
    E.parent_entity(load_game_txt, text)

    exit_game_txt, w, h = centered_string_main_menu("Exit", text_line, text_fill)
    E.set_entity_alpha(exit_game_txt, 0.0) -- hidden
    E.set_entity_scale(exit_game_txt, 0.095, 0.095, 1)
    E.set_entity_position(exit_game_txt, 0, -0.2, viewport.depth_bisect-1)
    E.parent_entity(exit_game_txt, text)

    load_game_txt2, w, h = centered_string_main_menu("Load Game", text_line, text_select)
    E.set_entity_flags(load_game_txt2, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(load_game_txt2, 0.125, 0.125, 1)
    E.set_entity_position(load_game_txt2, 0, h-0.1, viewport.depth_bisect-1)
    E.parent_entity(load_game_txt2, text)
    
    selected_index = 0
    show_load_menu = false
    load_index = 10

    for i = 0, 9 do
       local num_string = tostring(i)
       file_exist[i] = io.open(media_dir .. "game_state" .. num_string .. ".sav")
    end
    file_exist[10] = true

    game_state1, w, h = centered_string_main_menu("Game State 1", text_line, text_fill_color(file_exist[1]))
    E.set_entity_flags(game_state1, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state1, 0.075, 0.075, 1)
    E.set_entity_position(game_state1, 0, h-0.4, viewport.depth_bisect-1)
    E.parent_entity(game_state1, text)

    game_state2, w, h = centered_string_main_menu("Game State 2", text_line, text_fill_color(file_exist[2]))
    E.set_entity_flags(game_state2, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state2, 0.075, 0.075, 1)
    E.set_entity_position(game_state2, 0, h-0.5, viewport.depth_bisect-1)
    E.parent_entity(game_state2, text)
    
    game_state3, w, h = centered_string_main_menu("Game State 3", text_line, text_fill_color(file_exist[3]))
    E.set_entity_flags(game_state3, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state3, 0.075, 0.075, 1)
    E.set_entity_position(game_state3, 0, h-0.6, viewport.depth_bisect-1)
    E.parent_entity(game_state3, text)
    
    game_state4, w, h = centered_string_main_menu("Game State 4", text_line, text_fill_color(file_exist[4]))
    E.set_entity_flags(game_state4, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state4, 0.075, 0.075, 1)
    E.set_entity_position(game_state4, 0, h-0.7, viewport.depth_bisect-1)
    E.parent_entity(game_state4, text)
    
    game_state5, w, h = centered_string_main_menu("Game State 5", text_line, text_fill_color(file_exist[5]))
    E.set_entity_flags(game_state5, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state5, 0.075, 0.075, 1)
    E.set_entity_position(game_state5, 0, h-0.8, viewport.depth_bisect-1)
    E.parent_entity(game_state5, text)
    
    game_state6, w, h = centered_string_main_menu("Game State 6", text_line, text_fill_color(file_exist[6]))
    E.set_entity_flags(game_state6, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state6, 0.075, 0.075, 1)
    E.set_entity_position(game_state6, 0, h-0.9, viewport.depth_bisect-1)
    E.parent_entity(game_state6, text)
    
    game_state7, w, h = centered_string_main_menu("Game State 7", text_line, text_fill_color(file_exist[7]))
    E.set_entity_flags(game_state7, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state7, 0.075, 0.075, 1)
    E.set_entity_position(game_state7, 0, h-1.0, viewport.depth_bisect-1)
    E.parent_entity(game_state7, text)
    
    game_state8, w, h = centered_string_main_menu("Game State 8", text_line, text_fill_color(file_exist[8]))
    E.set_entity_flags(game_state8, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state8, 0.075, 0.075, 1)
    E.set_entity_position(game_state8, 0, h-1.1, viewport.depth_bisect-1)
    E.parent_entity(game_state8, text)
    
    game_state9, w, h = centered_string_main_menu("Game State 9", text_line, text_fill_color(file_exist[9]))
    E.set_entity_flags(game_state9, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state9, 0.075, 0.075, 1)
    E.set_entity_position(game_state9, 0, h-1.2, viewport.depth_bisect-1)
    E.parent_entity(game_state9, text)
    
    game_state0, w, h = centered_string_main_menu("Game State 0", text_line, text_fill_color(file_exist[0]))
    E.set_entity_flags(game_state0, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(game_state0, 0.075, 0.075, 1)
    E.set_entity_position(game_state0, 0, h-0.3, viewport.depth_bisect-1)
    E.parent_entity(game_state0, text)
    
    go_back, w, h = centered_string_main_menu("Back", text_line, text_select)
    E.set_entity_flags(go_back, E.entity_flag_hidden, true) -- hidden
    E.set_entity_scale(go_back, 0.055, 0.055, 1)
    E.set_entity_position(go_back, 0, h-1.35, viewport.depth_bisect-1)
    E.parent_entity(go_back, text)
    
    	
    --camera = E.create_camera(E.camera_type_perspective)
    game_opening_pivot = E.create_pivot()
    E.set_entity_flags(game_opening_pivot, E.entity_flag_hidden, true)

    local images_game_opening = E.create_pivot()
    local text_game_opening = E.create_pivot()
	
	E.parent_entity(game_opening_pivot, camera)
    E.parent_entity(images_game_opening, game_opening_pivot )
    E.parent_entity(text_game_opening, images_game_opening )

    E.set_background(0.0, 0.0, 0.0)
    
    --E.play_sound(intro_music)
    
    open1 = make_opaque_image_billboard(media_dir .. "open1.jpg")
    E.set_entity_alpha(open1, 0.0) -- hidden
    fit_to_view(open1, 0.7, 0.768, 0, 0)
    E.parent_entity(open1, images_game_opening)
    
    open2 = make_opaque_image_billboard(media_dir .. "open2.jpg")
    E.set_entity_alpha(open2, 0.0) -- hidden
    fit_to_view(open2, 0.718, 0.7, 0, 0)
    E.parent_entity(open2, images_game_opening)
    
    open3 = make_opaque_image_billboard(media_dir .. "open3.jpg")
    E.set_entity_alpha(open3, 0.0) -- hidden
    fit_to_view(open3, 0.8, 0.692, 0, 0.0)
    E.parent_entity(open3, images_game_opening)
    
    open4 = make_opaque_image_billboard(media_dir .. "open4.jpg")
    E.set_entity_alpha(open4, 0.0) -- hidden
    fit_to_view(open4, 0.82, 0.55, 0, 0)
    E.parent_entity(open4, images_game_opening)
    
    open5 = make_opaque_image_billboard(media_dir .. "open5.jpg")
    E.set_entity_alpha(open5, 0.0) -- hidden
    fit_to_view(open5, 0.75, 0.697, 0, 0.0)
    E.parent_entity(open5, images_game_opening)
    
    open6 = make_opaque_image_billboard(media_dir .. "open6.jpg")
    E.set_entity_alpha(open6, 0.0) -- hidden
    fit_to_view(open6, 0.775, 0.52, 0, 0)
    E.parent_entity(open6, images_game_opening)
    
    --E.set_typeface(media_dir .. "VeraBD.ttf", 0.001, 0.0)
    --E.set_typeface(media_dir .. "Nou.ttf", 0.001, 0.03)

    text_fill_game_opening = E.create_brush()
    E.set_brush_color(text_fill_game_opening, 1.0, 0.0, 0.0, 0.8)
    E.set_brush_flags(text_fill_game_opening, E.brush_flag_unlit, true)

    text_line_game_opening = E.create_brush()
    E.set_brush_color(text_line_game_opening, 1.0, 0.0, 0.0, 0.8)
    E.set_brush_flags(text_line_game_opening, E.brush_flag_unlit, true)

    -- open1_text
    --"Your name is Shane Wayne. You're an average schmuck"
    --"with a crappy gig down at the local art museum."
    open1_text1, w, h = centered_string_game_opening("Your name is Wayne Kitsch. You're an average schmuck", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open1_text1, 0.0) -- hidden
    E.set_entity_flags(open1_text1, E.entity_flag_hidden, true)
    E.set_entity_scale(open1_text1, 0.065, 0.065, 1)
    E.set_entity_position(open1_text1, -w + (w+0.06)/4 , -h + 0.15, 0)
    E.parent_entity(open1_text1, text_game_opening)
    
    open1_text2, w, h = centered_string_game_opening("with a crappy gig down at the local art museum.", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open1_text2, 0.0) -- hidden
    E.set_entity_flags(open1_text2, E.entity_flag_hidden, true)
    E.set_entity_scale(open1_text2, 0.065, 0.065, 1)
    E.set_entity_position(open1_text2, -w + (w+0.06)/4, -h + 0.10, 0)
    E.parent_entity(open1_text2, text_game_opening)
    
    -- open2_text
    --"Your payment for standing 8 hours a day is blisters,"
    --"calluses, boredom and minimum wage."
    open2_text1, w, h = centered_string_game_opening("Your payment for standing 8 hours a day is blisters,", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open2_text1, 0.0) -- hidden
    E.set_entity_flags(open2_text1, E.entity_flag_hidden, true)
    E.set_entity_scale(open2_text1, 0.065, 0.065, 1)
    E.set_entity_position(open2_text1, -w + (w+0.045)/4 , -h + 0.20, 0)
    E.parent_entity(open2_text1, text_game_opening)
    
    open2_text2, w, h = centered_string_game_opening("calluses, boredom and minimum wage.", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open2_text2, 0.0) -- hidden
    E.set_entity_flags(open2_text2, E.entity_flag_hidden, true)
    E.set_entity_scale(open2_text2, 0.065, 0.065, 1)
    E.set_entity_position(open2_text2, -w + (w+0.045)/4, -h + 0.15, 0)
    E.parent_entity(open2_text2, text_game_opening)

    -- open3_text
    --"To make matters worse, you despise art. You don't 'get'"
    --"it. And each day sucks worse than the previous."
    open3_text1, w, h = centered_string_game_opening("To make matters worse, you despise art. You don't 'get'", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open3_text1, 0.0) -- hidden
    E.set_entity_flags(open3_text1, E.entity_flag_hidden, true)
    E.set_entity_scale(open3_text1, 0.065, 0.065, 1)
    E.set_entity_position(open3_text1, -w + (w+0.045)/4 , -h + 0.20, 0)
    E.parent_entity(open3_text1, text_game_opening)
    
    open3_text2, w, h = centered_string_game_opening("it. And each day sucks worse than the previous.", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open3_text2, 0.0) -- hidden
    E.set_entity_flags(open3_text2, E.entity_flag_hidden, true)
    E.set_entity_scale(open3_text2, 0.065, 0.065, 1)
    E.set_entity_position(open3_text2, -w + (w+0.045)/4, -h + 0.15, 0)
    E.parent_entity(open3_text2, text_game_opening)
    
    -- open4_text
    --"Until one day..."
    open4_text, w, h = centered_string_game_opening("Until one day...", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open4_text, 0.0) -- hidden
    E.set_entity_flags(open4_text, E.entity_flag_hidden, true)
    E.set_entity_scale(open4_text, 0.065, 0.065, 1)
    E.set_entity_position(open4_text, -0.18 , -h + 0.3, 0)
    E.parent_entity(open4_text, text_game_opening)
    
    -- open5_text
    --"\"Ok tough guy, today's your lucky day, I'll make"
    --"you rich. Listen, my client wants a painting for"
    --"his dining room. Steal the Kandinsky and I'll hook"
    --"you up so you can retire in the Caribbean."
    --"Otherwise, your ass is grass. Case the joint at"
    --"work today and steal that shiz tonight.\" "
    open5_text1, w, h = centered_string_game_opening("\"Ok tough guy, today's your lucky day, I'll make", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open5_text1, 0.0) -- hidden
    E.set_entity_flags(open5_text1, E.entity_flag_hidden, true)
    E.set_entity_scale(open5_text1, 0.065, 0.065, 1)
    E.set_entity_position(open5_text1, -w + (w+0.5)/4 , -h + 0.65, 0)
    E.parent_entity(open5_text1, text_game_opening)
    
    open5_text2, w, h = centered_string_game_opening("you rich. Listen, my client wants a painting for", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open5_text2, 0.0) -- hidden
    E.set_entity_flags(open5_text2, E.entity_flag_hidden, true)
    E.set_entity_scale(open5_text2, 0.065, 0.065, 1)
    E.set_entity_position(open5_text2, -w + (w+0.5)/4, -h + 0.60, 0)
    E.parent_entity(open5_text2, text_game_opening)
    
    open5_text3, w, h = centered_string_game_opening("his dining room. Steal the Kandinsky and I'll", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open5_text3, 0.0) -- hidden
    E.set_entity_flags(open5_text3, E.entity_flag_hidden, true)
    E.set_entity_scale(open5_text3, 0.065, 0.065, 1)
    E.set_entity_position(open5_text3, -w + (w+0.5)/4 , -h + 0.55, 0)
    E.parent_entity(open5_text3, text_game_opening)

    open5_text4, w, h = centered_string_game_opening("hook you up so you can retire in the Caribbean.", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open5_text4, 0.0) -- hidden
    E.set_entity_flags(open5_text4, E.entity_flag_hidden, true)
    E.set_entity_scale(open5_text4, 0.065, 0.065, 1)
    E.set_entity_position(open5_text4, -w + (w+0.5)/4, -h + 0.50, 0)
    E.parent_entity(open5_text4, text_game_opening)
    
    open5_text5, w, h = centered_string_game_opening("Otherwise, your ass is grass. Case the joint at", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open5_text5, 0.0) -- hidden
    E.set_entity_flags(open5_text5, E.entity_flag_hidden, true)
    E.set_entity_scale(open5_text5, 0.065, 0.065, 1)
    E.set_entity_position(open5_text5, -w + (w+0.5)/4, -h + 0.45, 0)
    E.parent_entity(open5_text5, text_game_opening)
    
    open5_text6, w, h = centered_string_game_opening("work today and steal that shiz tonight.\"", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open5_text6, 0.0) -- hidden
    E.set_entity_flags(open5_text6, E.entity_flag_hidden, true)
    E.set_entity_scale(open5_text6, 0.065, 0.065, 1)
    E.set_entity_position(open5_text6, -w + (w+0.5)/4, -h + 0.40, 0)
    E.parent_entity(open5_text6, text_game_opening)
    
    -- open6_text
    --"\"But I don't know jack about art.\""
    --"\"Not my problem. Steal the Kandinsky\""
    open6_text1, w, h = centered_string_game_opening("\"But I don't know jack about art.\"", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open6_text1, 0.0) -- hidden
    E.set_entity_flags(open6_text1, E.entity_flag_hidden, true)
    E.set_entity_scale(open6_text1, 0.065, 0.065, 1)
    E.set_entity_position(open6_text1, -w + (w+2)/4 , -h + 0.6, 0)
    E.parent_entity(open6_text1, text_game_opening)
    
    open6_text2, w, h = centered_string_game_opening("\"Not my problem. Steal the Kandinsky\"", text_line_game_opening, text_fill_game_opening)
    E.set_entity_alpha(open6_text2, 0.0) -- hidden
    E.set_entity_flags(open6_text2, E.entity_flag_hidden, true)
    E.set_entity_scale(open6_text2, 0.065, 0.065, 1)
    E.set_entity_position(open6_text2, -w + (w+0.8)/4, -h + 0.7, 0)
    E.parent_entity(open6_text2, text_game_opening)
    
    press_enter, w, h = centered_string_game_opening("Press Enter to Continue", text_line_game_opening, text_fill_game_opening)
    --E.set_entity_alpha(press_enter, 0.0) -- hidden
    --E.set_entity_flags(press_enter, E.entity_flag_hidden, true)
    E.set_entity_scale(press_enter, 0.045, 0.045, 1)
    E.set_entity_position(press_enter, (w + 0.1)/4, -h + 0.05, 0)
    E.parent_entity(press_enter, text_game_opening)

end

init_main_menu()