local Msn_proto_select_doc = 0
local Input_tracker
local Mouse_input_tracker = 0
local Mouse_back_input_tracker = 0
local Hint_bar = 0
local Cur_audio_id = -1
local MSN_PROTO_SELECT_STATE_INIT = 0
local MSN_PROTO_SELECT_STATE_GRID = 1
local MSN_PROTO_SELECT_STATE_ACCEPT = 2
local Msn_proto_select_state = MSN_PROTO_SELECT_STATE_INIT
local MSN_PROTO_SWATCHES_SPACING_X = 206
local MSN_PROTO_SWATCHES_SPACING_X = 206
local MSN_PROTO_DEFAULT_SELECTOR_WIDTH = 612 --Default size of selector below swatches..
local MSN_PROTO_DEFAULT_SELECTOR_X_OFFSET = 113 --offset from swatch corner...
local MSN_PROTO_DEFAULT_SELECTOR_Y_OFFSET = 206 --offset from swatch corner...
local MSN_PROTO_ACCEPT_SELECTOR_X = 113 --offset from swatch corner...
local MSN_PROTO_ACCEPT_SELECTOR_Y = 390 --offset from swatch corner...
local MSN_PROTO_COLOR_HIGHLIGHT = {R = 216/255, G = 105/255, B = 26/255}
local MSN_PROTO_COLOR_NORMAL = {R = 172/255, G = 84/255, B = 20/255}
Right_side_twns = {}
Msn_proto_disconnect_dialog_handle = 0
Msn_proto_select_update_thread_handle = -1
Msn_proto_intro_audio_id = -1
Msn_proto_outro_audio_id = -1
Msn_proto_use_buttons_on_highlights = true
local Msn_proto_swatches = {
[1] = {
image = "ui_msn_proto_bike",
item_name = "MSN_PROTO_SELECT_BIKE_TITLE",
item_description = "MSN_PROTO_SELECT_BIKE_DESC",
selector_x_offset = 0,
},
[2] = {
image = "ui_msn_proto_satchel",
item_name = "MSN_PROTO_SELECT_SATCHEL_TITLE",
item_description = "MSN_PROTO_SELECT_SATCHEL_DESC",
selector_x_offset = 0,
},
[3] = {
image = "ui_msn_proto_tank",
item_name = "MSN_PROTO_SELECT_TANK_TITLE",
item_description = "MSN_PROTO_SELECT_TANK_DESC",
selector_x_offset = 0,
},
}
local Msn_proto_swatch_selected = 1
local Msn_items_selected = {}
local Msn_num_items_selected = 0
local Selector_bmp_h = 0
local Msn_proto_select_is_host = true
function msn_proto_select_init()
--Msn_proto_select_doc = vint_document_find("msn_proto_select")
if vint_is_std_res() then
--dim out parts that will flicker in standard def
local right_side_boxes_h = vint_object_find("right_side_boxes")
local right_side_elements_h = vint_object_find("right_side_elements")
vint_set_property(right_side_boxes_h, "alpha", .33)
vint_set_property(right_side_elements_h, "alpha", .33)
end
--Figure out stuff for bottom line graph animation...
local anim_h = vint_object_find("bottom_graph_line_anim")
local bottom_graph_line_h = vint_object_find("bottom_graph_line")
local bottom_graph_cap_twn_h = vint_object_find("bottom_graph_cap_twn")
local bottom_graph_line_twn_h = vint_object_find("bottom_graph_line_twn")
local line_grp_h = bottom_graph_line_h
local cap_twn_h = bottom_graph_cap_twn_h
local line_twn_h = bottom_graph_line_twn_h
local total_loops = 40
for i = 0, total_loops do
if i > 0 then
line_grp_h = vint_object_clone(bottom_graph_line_h)
cap_twn_h = vint_object_clone(bottom_graph_cap_twn_h)
line_twn_h = vint_object_clone(bottom_graph_line_twn_h)
end
local x, y = vint_get_property(line_grp_h, "anchor")
x = i * 4
vint_set_property(line_grp_h, "anchor", x, y)
local line_h = vint_object_find("bottom_vert_line", line_grp_h)
local cap_h = vint_object_find("bottom_vert_line_cap", line_grp_h)
local rand_time = rand_float(.01,.2)
vint_set_property(cap_twn_h, "start_time", i * (.1 + rand_time))
vint_set_property(line_twn_h, "start_time", i * (.1 + rand_time))
vint_set_property(line_twn_h, "duration", .5 + rand_time )
vint_set_property(cap_twn_h, "duration", .5+ rand_time )
vint_set_property(cap_twn_h, "target_handle", cap_h)
vint_set_property(line_twn_h, "target_handle", line_h)
end
--Play Bottom line graph animation..
lua_play_anim(anim_h, -5)
--Figure out stuff for right line graph animation...
anim_h = vint_object_find("right_graph_line_anim")
local right_graph_bar_h = vint_object_find("right_graph_bar")
local right_line_cap_h = vint_object_find("right_line_cap_anchor_twn")
local right_line_fill_h = vint_object_find("right_line_fill_scale_twn")
local line_grp_h = right_graph_bar_h
local cap_twn_h = right_line_cap_h
local line_twn_h = right_line_fill_h
--Figure out stuff for bottom line graph animation...
local total_loops = 8
for i = 0, total_loops do
if i > 0 then
line_grp_h = vint_object_clone(right_graph_bar_h)
cap_twn_h = vint_object_clone(right_line_cap_h)
line_twn_h = vint_object_clone(right_line_fill_h)
end
local x, y = vint_get_property(line_grp_h, "anchor")
y = i * 12
vint_set_property(line_grp_h, "anchor", x, y)
local line_h = vint_object_find("right_line_fill", line_grp_h)
local cap_h = vint_object_find("right_line_cap", line_grp_h)
local rand_time = rand_float(.01,.2)
vint_set_property(cap_twn_h, "start_time", i * (.1 + rand_time))
local start_time = i * (.1 + rand_time)
if start_time < .1 then
start_time = .1
end
vint_set_property(line_twn_h, "start_time", start_time)
vint_set_property(line_twn_h, "duration", .1 + rand_time )
local max_scale = 25.4
local min_scale = 0.1
local y_scale = 0.625
local min_x = 9
local max_x = 413
local rand_min = rand_float(.1,1)
local rand_max = rand_float(.1,1)
local target_min_scale = min_scale + (max_scale - min_scale) * rand_min
local target_max_scale = min_scale + (max_scale - min_scale) * rand_max
local target_min_x = min_x + (max_x - min_x) * rand_min
local target_max_x = min_x + (max_x - min_x) * rand_max
vint_set_property(line_twn_h, "start_value", target_min_scale, y_scale)
vint_set_property(line_twn_h, "end_value", target_max_scale, y_scale)
vint_set_property(cap_twn_h, "start_value", target_min_x, 0 )
vint_set_property(cap_twn_h, "end_value", target_max_x, 0 )
vint_set_property(cap_twn_h, "duration", 2 + rand_time )
vint_set_property(line_twn_h, "duration", 2 + rand_time )
vint_set_property(cap_twn_h, "target_handle", cap_h)
vint_set_property(line_twn_h, "target_handle", line_h)
Right_side_twns[line_twn_h] = {cap_twn_h = cap_twn_h, cap_h = cap_h, line_h = line_h}
vint_set_property(line_twn_h, "end_event", "msn_proto_right_side_cb")
end
--Play Right line graph animation..
lua_play_anim(anim_h)
local Msn_proto_select_update_thread_handle = thread_new("msn_proto_update_txt")
--Check to see if we have an active gamepad...
if game_is_active_input_gamepad() == false then
--remove all buttons
Msn_proto_use_buttons_on_highlights = false
end
--Build swatches...
msn_proto_swatches_build()
msn_proto_swatches_highlight(1)
local header1_txt_h = vint_object_find("header1_txt")
local header2_txt_h = vint_object_find("header2_txt")
vint_set_property(header2_txt_h, "text_tag", "MSN_PROTO_SELECT_OPTION_1")
--hide hintbar
Hint_bar = Vdo_hint_bar:new("main_hint_bar")
Hint_bar:set_visible(false)
Hint_bar:set_highlight(1, MSN_PROTO_COLOR_NORMAL)
Msn_proto_select_is_host = game_get_is_host()
if Msn_proto_select_is_host then
--Do input subscription...
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("pause", "msn_proto_select_pause", 50)
Input_tracker:add_input("select", "msn_proto_select_input_a", 50)
Input_tracker:add_input("back", "msn_proto_select_input_b", 50)
Input_tracker:add_input("nav_up", "msn_proto_select_input_nav", 50)
Input_tracker:add_input("nav_down", "msn_proto_select_input_nav", 50)
Input_tracker:add_input("nav_left", "msn_proto_select_input_nav", 50)
Input_tracker:add_input("nav_right", "msn_proto_select_input_nav", 50)
Input_tracker:subscribe(true)
--Set button image on selector
local button = Vdo_hint_button:new("button", vint_object_find("selector"))
button:set_button(CTRL_MENU_BUTTON_A)
if game_get_platform() == "PC" then
local selector_h = vint_object_find("selector")
Selector_bmp_h = vint_object_find("selector_bmp", selector_h)
--Setup hints...
local hint_data = {
{CTRL_MENU_BUTTON_B, "MENU_BACK"},
}
Hint_bar:set_hints(hint_data)
Mouse_input_tracker = Vdo_input_tracker:new()
msn_proto_mouse_input_add()
Mouse_back_input_tracker = Vdo_input_tracker:new()
end
else
--coop player gets no options and we should overwrite some values.
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("map", "msn_proto_coop_input", 50)
Input_tracker:subscribe(true)
--Hide selector
msn_proto_swatches_highlight(-1, true)
--Setup hints...
local hint_data = {
{CTRL_MENU_BUTTON_BACK, "COMPLETION_COOP_DISCONNECT"},
}
Hint_bar:set_hints(hint_data)
Hint_bar:set_visible(true)
if game_get_platform() == "PC" then
Mouse_back_input_tracker = Vdo_input_tracker:new()
Hint_bar:add_mouse_inputs("msn_proto", Mouse_back_input_tracker)
Mouse_back_input_tracker:subscribe(true)
end
--set selector to say coop options...
msn_proto_selector_update("MSN_PROTO_COOP_WAIT_ACTION", "MSN_PROTO_COOP_WAIT_DESC", MSN_PROTO_ACCEPT_SELECTOR_X, MSN_PROTO_ACCEPT_SELECTOR_Y, false)
end
msn_proto_state_set(MSN_PROTO_SELECT_STATE_GRID)
local intro_audio = "ui_stag_prototype_screen"
Msn_proto_intro_audio_id = audio_object_post_event(intro_audio)
end
function msn_proto_select_pause()
dialog_open_pause_display()
end
function msn_proto_right_side_cb(tween_h)
local line_twn_h = tween_h
local cap_twn_h = Right_side_twns[tween_h].cap_twn_h
local cap_h = Right_side_twns[tween_h].cap_h
local line_h = Right_side_twns[tween_h].line_h
local max_scale = 25.4
local min_scale = 0.1
local y_scale = 0.625
local min_x = 9
local max_x = 413
local rand_min = rand_float(.1,1)
local rand_max = rand_float(.1,1)
local target_max_scale = min_scale + (max_scale - min_scale) * rand_max
local target_max_x = min_x + (max_x - min_x) * rand_max
local start_scale_x, start_scale_y = vint_get_property(line_h, "scale")
local start_x, start_y = vint_get_property(cap_h, "anchor")
local should_i_wait = rand_int(1,3)
if should_i_wait == 1 then
target_max_scale = start_scale_x
target_max_x = start_x
end
vint_set_property(line_twn_h, "start_value", start_scale_x, y_scale)
vint_set_property(line_twn_h, "end_value", target_max_scale, y_scale)
vint_set_property(cap_twn_h, "start_value", start_x, 0)
vint_set_property(cap_twn_h, "end_value", target_max_x, 0)
local rand_time = rand_float(1.01,2.2)
vint_set_property(cap_twn_h, "duration", rand_time)
vint_set_property(line_twn_h, "duration", rand_time)
--algorithm...
local algorithms = {"ease_in_out_quad", "ease_in_out_exp"}
local algorithm = algorithms[rand_int(1, #algorithms-1)]
vint_set_property(cap_twn_h, "algorithm", algorithm)
vint_set_property(line_twn_h, "algorithm", algorithm)
local time_index = vint_get_time_index(Msn_proto_select_doc)
vint_set_property(cap_twn_h, "start_time", time_index)
vint_set_property(line_twn_h, "start_time", time_index)
end
function msn_proto_select_cleanup()
if Msn_proto_select_update_thread_handle ~= -1 then
thread_kill(Msn_proto_select_update_thread_handle)
end
end
function msn_proto_swatches_build()
local swatch_handle
local swatch_handle_base = vint_object_find("swatch")
local x, y = vint_get_property(swatch_handle_base, "anchor")
local start_x = x
local start_y = y
local num_swatches = #Msn_proto_swatches
for i = 1, num_swatches do
if i == 1 then
swatch_handle = swatch_handle_base
else
swatch_handle = vint_object_clone(swatch_handle_base)
end
--reposition
x = start_x + (MSN_PROTO_SWATCHES_SPACING_X * (i - 1))
vint_set_property(swatch_handle, "anchor", x, y)
local image_h = vint_object_find("swatch_img", swatch_handle)
vint_set_property(image_h,"image", Msn_proto_swatches[i].image)
--Set button image
local button = Vdo_hint_button:new("button", swatch_handle)
button:set_button(CTRL_MENU_BUTTON_A)
--unselect every swatch...
msn_proto_swatches_select(i, false)
Msn_proto_swatches[i].handle = swatch_handle
Msn_proto_swatches[i].is_selected = false
end
end
function msn_proto_swatches_highlight(idx, selector_is_disabled)
local num_swatches = #Msn_proto_swatches
local swatch_selector_h = vint_object_find("swatch_selector")
if selector_is_disabled == true then
vint_set_property(swatch_selector_h, "visible", false)
else
vint_set_property(swatch_selector_h, "visible", true)
end
for i = 1, num_swatches do
local swatch_h = Msn_proto_swatches[i].handle
local button_h = vint_object_find("button", swatch_h)
if i == idx then
--Move selector
local x, y = vint_get_property(swatch_h, "anchor")
vint_set_property(swatch_selector_h, "anchor", x, y)
if not selector_is_disabled then
--only adjust the alpha if our selector is not disabled, weird i know but we override this when the selector is disabled somewhere else...
vint_set_property(swatch_h, "alpha", 1)
end
if Msn_proto_use_buttons_on_highlights then
-- show (A) button
vint_set_property(button_h, "visible", true)
else
vint_set_property(button_h, "visible", false)
end
--Move selector
local item_name = Msn_proto_swatches[i].item_name
local item_description = Msn_proto_swatches[i].item_description
msn_proto_selector_update(item_name, item_description, MSN_PROTO_DEFAULT_SELECTOR_X_OFFSET, MSN_PROTO_ACCEPT_SELECTOR_Y)
else
if not selector_is_disabled then
--only adjust the alpha if our selector is not disabled, weird i know but we override this when the selector is disabled somewhere else...
--set unselected..
vint_set_property(swatch_h, "alpha", .8)
end
-- hide (A) button
vint_set_property(button_h, "visible", false)
end
end
--override alpha on for all the swatches...
if Msn_proto_select_state == MSN_PROTO_SELECT_STATE_ACCEPT then
local item_1_selected = Msn_items_selected[0]
local item_2_selected = Msn_items_selected[1]
for loop_idx, val in pairs(Msn_proto_swatches) do
local alpha = 1
if loop_idx ~= item_2_selected and loop_idx ~= item_1_selected then
--Dim non selected items..
alpha = .2
end
vint_set_property(val.handle, "alpha", alpha)
end
end
end
function msn_proto_swatches_select(idx, is_selected)
local swatch_h = Msn_proto_swatches[idx].handle
local checkbox_h = vint_object_find("checkbox", swatch_h)
vint_set_property(checkbox_h, "visible", is_selected)
--Store selection...
Msn_proto_swatches[idx].is_selected = is_selected
end
function msn_proto_selector_update(title_txt, description_txt, x, y, has_button)
local selector_h = vint_object_find("selector")
--Set width of selector...
local selector_bmp_h = vint_object_find("selector_bmp", selector_h)
local selector_width, selector_height = element_get_actual_size(selector_bmp_h)
element_set_actual_size(selector_bmp_h, MSN_PROTO_DEFAULT_SELECTOR_WIDTH, selector_height)
--Set text elements...
local selector_header_txt_h = vint_object_find("selector_header_txt", selector_h)
local selector_desc_txt_h = vint_object_find("selector_desc_txt", selector_h)
vint_set_property(selector_header_txt_h, "text_tag", title_txt)
vint_set_property(selector_desc_txt_h, "text_tag", description_txt)
--Move selector
vint_set_property(selector_h, "anchor", x, y)
--Change text alignment
local header_x, header_y = vint_get_property(selector_header_txt_h, "anchor")
local button_h = vint_object_find("button", selector_h)
if has_button == true and Msn_proto_use_buttons_on_highlights then
vint_set_property(selector_header_txt_h, "anchor", 38, header_y)
vint_set_property(button_h, "visible", true)
else
vint_set_property(selector_header_txt_h, "anchor", 8, header_y)
vint_set_property(button_h, "visible", false)
end
end
function msn_proto_selector_highlight(is_highlighted)
local selector_h = vint_object_find("selector")
local selector_bmp_h = vint_object_find("selector_bmp", selector_h)
local selector_header_txt_h = vint_object_find("selector_header_txt", selector_h)
--local text_color = {1/255, 8/255, 13/255}
--
--local selector_color_2 = {231/255, 126/255, 50/255}
local selector_pulse_anim_h = vint_object_find("selector_pulse_anim")
if is_highlighted == true then
--vint_set_property(selector_bmp_h, "tint", selector_color_2[1], selector_color_2[2], selector_color_2[3])
--vint_set_property(selector_header_txt_h, "tint", selector_color[1], selector_color[2], selector_color[3])
lua_play_anim(selector_pulse_anim_h)
else
vint_set_property(selector_pulse_anim_h, "is_paused", true)
vint_set_property(selector_bmp_h, "alpha", 1)
--vint_set_property(selector_header_txt_h, "tint", text_color[1], text_color[2], text_color[3])
--vint_set_property(selector_bmp_h, "tint", selector_color[1], selector_color[2], selector_color[3])
end
end
function msn_proto_select_cursor_move(direction)
if direction == -1 then
local num_swatches = #Msn_proto_swatches
Msn_proto_swatch_selected = Msn_proto_swatch_selected - 1
if Msn_proto_swatch_selected < 1 then
Msn_proto_swatch_selected = num_swatches
end
elseif direction == 1 then
local num_swatches = #Msn_proto_swatches
Msn_proto_swatch_selected = Msn_proto_swatch_selected + 1
if Msn_proto_swatch_selected > num_swatches then
Msn_proto_swatch_selected = 1
end
else
--bad direction return...
return
end
msn_proto_swatches_highlight(Msn_proto_swatch_selected)
end
-------------------------------------------------------------------------------
-- Nav left and right
--
function msn_proto_select_input_nav(event, acceleration)
--Exit early if we are in init state...
if Msn_proto_select_state == MSN_PROTO_SELECT_STATE_INIT then
return
end
--Naving left and right
if Msn_proto_select_state == MSN_PROTO_SELECT_STATE_GRID then
--Navigate the grid
if event == "nav_left" then
audio_object_post_event("ui_stag_prototype_scroll")
msn_proto_select_cursor_move(-1)
elseif event == "nav_right" then
audio_object_post_event("ui_stag_prototype_scroll")
msn_proto_select_cursor_move(1)
end
end
end
function msn_proto_select_input_a()
if Msn_proto_select_state == MSN_PROTO_SELECT_STATE_GRID then
--Select the item
local item_was_selected = msn_proto_select_item(Msn_proto_swatch_selected)
--only nav if we selected an item..
if item_was_selected then
msn_proto_select_cursor_move(1)
end
audio_object_post_event("ui_stag_prototype_select_press")
elseif Msn_proto_select_state == MSN_PROTO_SELECT_STATE_ACCEPT then
audio_stop(Msn_proto_intro_audio_id)
local audio_out = "ui_stag_prototype_screen_stop"
Msn_proto_outro_audio_id = audio_object_post_event(audio_out)
--Make selection
msn_proto_ready_to_exit()
end
end
function msn_proto_select_input_b()
if Msn_proto_select_state == MSN_PROTO_SELECT_STATE_ACCEPT then
--reset state if we are in the accept state...
msn_proto_state_set(MSN_PROTO_SELECT_STATE_GRID)
end
--Uncheck previous item and select it...
local last_item_selected = Msn_items_selected[Msn_num_items_selected-1]
if last_item_selected ~= nil then
msn_proto_select_item(last_item_selected)
Msn_proto_swatch_selected = last_item_selected
msn_proto_swatches_highlight(Msn_proto_swatch_selected)
end
if Mouse_input_tracker ~= 0 then
msn_proto_selector_highlight(false)
end
audio_object_post_event("ui_stag_prototype_cancel")
end
-------------------------------------------------------------------------------
-- Mouse inputs
--
function msn_proto_mouse_input_add()
for i = 1, #Msn_proto_swatches do
Mouse_input_tracker:add_mouse_input("mouse_move_always", "msn_proto_mouse_move", 50, Msn_proto_swatches[i].handle)
Mouse_input_tracker:add_mouse_input("mouse_click", "msn_proto_mouse_click", 50, Msn_proto_swatches[i].handle)
end
Mouse_input_tracker:add_mouse_input("mouse_move", "msn_proto_mouse_move", 50, Selector_bmp_h)
Mouse_input_tracker:add_mouse_input("mouse_click", "msn_proto_mouse_click", 50, Selector_bmp_h)
Mouse_input_tracker:subscribe(true)
end
function msn_proto_mouse_click(event, target_handle, mouse_x, mouse_y)
--Select an item...
local hint_bar_hit_index = Hint_bar:get_hint_index(target_handle)
if hint_bar_hit_index == 1 then
if Msn_proto_select_is_host then
msn_proto_select_input_b()
else
msn_proto_coop_input("map")
end
return
end
if Msn_proto_select_state == MSN_PROTO_SELECT_STATE_ACCEPT then
local found_hit = false
if target_handle == Selector_bmp_h then
found_hit = true
end
if found_hit == true then
--stop audio and play outro audio.
audio_stop(Msn_proto_intro_audio_id)
local audio_out = "ui_stag_prototype_screen_stop"
Msn_proto_outro_audio_id = audio_object_post_event(audio_out)
--Now lets exit...
msn_proto_ready_to_exit()
end
else
--Swatch Select
--loop through swatched to find the handle.
for i = 1, #Msn_proto_swatches do
if target_handle == Msn_proto_swatches[i].handle then
local item_1_selected = Msn_items_selected[0]
local item_2_selected = Msn_items_selected[1]
if (item_1_selected ~= nil and i == item_1_selected) or (i == item_2_selected and item_2_selected ~= nil) then
return
end
local selected = not Msn_proto_swatches[i].is_selected
audio_object_post_event("ui_stag_prototype_select_press")
msn_proto_select_item(i)
msn_proto_swatches_highlight(-1, true)
end
end
end
end
function msn_proto_mouse_move(event, target_handle)
local hint_bar_hit_index = Hint_bar:get_hint_index(target_handle)
if hint_bar_hit_index == 1 then
Hint_bar:set_highlight(1, MSN_PROTO_COLOR_HIGHLIGHT)
else
Hint_bar:set_highlight(1, MSN_PROTO_COLOR_NORMAL)
end
--highlight an item...
if Msn_proto_select_state == MSN_PROTO_SELECT_STATE_ACCEPT then
else
--Swatch Select
--loop through swatched to find the handle.
for i = 1, #Msn_proto_swatches do
if target_handle == Msn_proto_swatches[i].handle then
if Msn_proto_swatch_selected ~= i then
if Msn_proto_select_state == MSN_PROTO_SELECT_STATE_ACCEPT then
--No highlighting if in accept state...
return
end
local item_1_selected = Msn_items_selected[0]
local item_2_selected = Msn_items_selected[1]
if (item_1_selected ~= nil and i == item_1_selected) or (i == item_2_selected and item_2_selected ~= nil) then
return
end
audio_object_post_event("ui_stag_prototype_scroll")
msn_proto_swatches_highlight(i)
Msn_proto_swatch_selected = i
end
end
end
end
end
function msn_proto_mouse_drag(event, target_handle, mouse_x, mouse_y)
end
function msn_proto_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
end
function msn_proto_select_item(idx)
local item_was_selected = true
if Msn_proto_swatches[idx].is_selected == false then
--select item in list...
msn_proto_swatches_select(idx, true)
--add items to our selected list...
Msn_items_selected[Msn_num_items_selected] = idx
Msn_num_items_selected = Msn_num_items_selected + 1
else
--unselect item in list...
msn_proto_swatches_select(idx, false)
--remove entry in our selected list...
for loop_idx, val in pairs(Msn_items_selected) do
if val == idx then
Msn_items_selected[loop_idx] = nil
end
end
--decrement items selected...
Msn_num_items_selected = Msn_num_items_selected - 1
item_was_selected = false
end
local header2_txt_h = vint_object_find("header2_txt")
if Msn_num_items_selected == 0 then
vint_set_property(header2_txt_h, "text_tag", "MSN_PROTO_SELECT_OPTION_1")
elseif Msn_num_items_selected == 1 then
vint_set_property(header2_txt_h, "text_tag", "MSN_PROTO_SELECT_OPTION_2")
elseif Msn_num_items_selected == 2 then
vint_set_property(header2_txt_h, "text_tag", "MSN_PROTO_SELECT_OPTION_3")
end
local pulse_objective_anim_h = vint_object_find("pulse_objective_anim")
lua_play_anim(pulse_objective_anim_h)
--if 2 items are selected then we are ready to go...
if Msn_num_items_selected == 2 then
--Change state...
msn_proto_state_set(MSN_PROTO_SELECT_STATE_ACCEPT)
--highlight accept button...
local item_1_selected = Msn_items_selected[0]
local item_2_selected = Msn_items_selected[1]
local item_1_name = Msn_proto_swatches[item_1_selected].item_name
local item_2_name = Msn_proto_swatches[item_2_selected].item_name
for idx, val in pairs(Msn_proto_swatches) do
local alpha = 1
if idx ~= item_2_selected and idx ~= item_1_selected then
--Dim non selected items..
alpha = .2
end
vint_set_property(val.handle, "alpha", alpha)
end
local values = {[0] = item_1_name, [1] = item_2_name}
local accept_description_txt = vint_insert_values_in_string("MSN_PROTO_CONFIRM_DESC", values)
msn_proto_selector_update("MSN_PROTO_CONFIRM_ACTION", accept_description_txt, MSN_PROTO_ACCEPT_SELECTOR_X, MSN_PROTO_ACCEPT_SELECTOR_Y, true)
--unhighlight
msn_proto_swatches_highlight(-1, true)
end
if Msn_num_items_selected > 0 then
msn_proto_back_button_show(true)
else
msn_proto_back_button_show(false)
end
return item_was_selected
end
-------------------------------------------------------------------------------
-- Changes state of our screen...
-- @state MSN_PROTO_SELECT_STATE_ACCEPT, MSN_PROTO_SELECT_STATE_GRID
--
function msn_proto_state_set(state)
if state == MSN_PROTO_SELECT_STATE_ACCEPT then
msn_proto_selector_highlight(true)
else
msn_proto_selector_highlight(false)
end
Msn_proto_select_state = state
end
function msn_proto_back_button_show(visible)
if Mouse_input_tracker ~= 0 then
Hint_bar:set_visible(visible)
Mouse_back_input_tracker:remove_all()
if visible then
--enable hints...
Hint_bar:add_mouse_inputs("msn_proto", Mouse_back_input_tracker)
Mouse_back_input_tracker:subscribe(true)
end
end
end
function msn_proto_ready_to_exit()
--Call C++ and tell it what items we have selected...
-- pseudo code below: pass game these variables... Msn_items_selected[0], Msn_items_selected[1]
game_proto_select(Msn_items_selected[0], Msn_items_selected[1])
-- unload_interface()
-- local document_h = vint_document_find("msn_proto_select")
-- vint_document_unload(document_h)
pop_screen()
end
-------------------------------------------------------------------------------
-- Player choice input for coop...
--
function msn_proto_coop_input(event)
if event == "map" then
--Coop quit dialog brings up the quit dialog for the coop player(Client) if they want to quit or not...
local options = { [0] = "CONTROL_YES", [1] = "CONTROL_NO" }
Msn_proto_disconnect_dialog_handle = dialog_box_open("MENU_TITLE_WARNING", "DIALOG_PAUSE_DISCONNECT_PROMPT", options, "msn_proto_coop_disconnect", 1, DIALOG_PRIORITY_SYSTEM_CRITICAL, true, nil, false, false)
end
end
-------------------------------------------------------------------------------
-- When the coop disconnect dialog closes... this is called.
--
function msn_proto_coop_disconnect(result, action)
--They selected yes...
if result == 0 then
dialog_box_disconnect()
end
Msn_proto_disconnect_dialog_handle = 0
end
---------------------------------------------------------------------------------------------------
-- Screen Animation Support.
--
function msn_proto_update_txt()
-- Left side text elements...
local core_temp_txt_h = vint_object_find("core_temp_txt")
local initialized_txt_h = vint_object_find("initialized_txt")
local processes_txt_h = vint_object_find("processes_txt")
local processing_txt_h = vint_object_find("processing_txt")
-- Right side text elements...
local speed_txt_h = vint_object_find("speed_txt")
local core_anal_1_txt_h = vint_object_find("core_anal_1_txt")
local core_anal_2_txt_h = vint_object_find("core_anal_2_txt")
-- SYSTEM STATUS...
local initialized_txt = "SYSTEM STATUS\nREADY"
vint_set_property(initialized_txt_h, "text_tag", initialized_txt)
-- Set CPU PCT...
local cpu_pct = rand_float(.1,1)
-- List of file names...
local process_list = {
"AEVEMENTS.XTBL",
"AON_NODES.XTBL",
"AON_NODE_NPCS.XTBL",
"A_ACTIONS.XTBL",
"A_AUTO.XTBL",
"A_AUTO_APC.XTBL",
"A_AUTO_MONSTER.XTBL",
"A_BIPLANE.XTBL",
"A_BLEND_TREES.XTBL",
"A_BOATS.XTBL",
"A_BOATS_CRAFT.XTBL",
"A_BOATS_SPED1.XTBL",
"A_BROTHERHOOD.XTBL",
"A_ENVIRONMENT.XTBL",
"A_FACE.XTBL",
"A_FILES.XTBL",
"A_FILES_FLAGS.XTBL",
"A_FLINCHES.XTBL",
"A_HELI.XTBL",
"A_HELIFIGHTER.XTBL",
"A_IK_LOCATION.XTBL",
"A_IK_SITUATION.XTBL",
"A_JET.XTBL",
"A_MOTO.XTBL",
"A_MOTO_ATV.XTBL",
"A_MOTO_CRUISER.XTBL",
"A_MOTO_DIRT.XTBL",
"A_MOTO_MOPED.XTBL",
"A_MOTO_ROCKET.XTBL",
"A_PLANES.XTBL",
"A_PLANE_STANDARD.XTBL",
"A_POLICE_4D.XTBL",
"A_PROP_SETS.XTBL",
"A_REACTIONS.XTBL",
"A_SET_FILENAMES.XTBL",
"A_SET_PROPERTIES.XTBL",
"A_STATES.XTBL",
"A_SYNCED.XTBL",
"A_TAGS.XML",
"A_TRANSITIONS.XTBL",
"A_TRIGGERS.XTBL",
"A_VEHICLES.XTBL",
"AO_CONSTANTS.XTBL",
"AO_EVENTS.XTBL",
"AO_LINE_TAGS.XTBL",
"AO_MARKERS.XTBL",
"AO_PERSONAS.XTBL",
"AO_SETTINGS.XTBL",
"AO_SYNCS.XTBL",
"BAP_MATERIALS.XTBL",
"BES.XTBL",
"BE.XTBL",
"BE_BRUISER.XTBL",
"BE_ZOMBIE.XTBL",
"CRA_FREE.XTBL",
"CRA_SHAKE.XTBL",
"CORAMP.XTBL",
"CDEALERSHIPS.XTBL",
"C_PHONE.XTBL",
"CACTER.XTBL",
"CTS.XTBL",
"CLIFE.XTBL",
"CSWT1.XTBL",
"CERCIALS.XTBL",
"MC_STORE.XTBL",
"NRIETY.XTBL",
"NRIETY_LEVELS.XTBL",
"NRIETY_SPAWN.XTBL",
"NCOLOR_PALETTE.XTBL",
"PCHUTE.XTBL",
"P.XTBL",
"P_LIFE.XTBL",
"PE_TABLE.XTBL",
"P.XTBL",
"P.XTBL",
"P_ZOMBIE.XTBL",
"PSTREAKER.XTBL",
"PON_YACHT.XTBL",
"RO_ACTIVITIES.XTBL",
"RO_EVENTS.XTBL",
"S_NAMES.XTBL",
"S_COLOR_POOL.XTBL",
"SOX_EFFECTS.XTBL",
"SEDOOR.XTBL",
"SE_WEAPONS.XTBL",
"SFE_ANGLES.XTBL",
"S_ROPE.XTBL",
"TOO_COLOR_POOL.XTBL",
"TS.XTBL",
"TR.XTBL",
"T_OF_DAY.XTBL",
"T_OF_DAY_OBJECTS.XTBL",
"TFIC_LANES.XTBL",
"TFIC_TYPES.XTBL",
"TGERS.XTBL",
"TK_TABLE.XTBL",
"UCKABLES.XTBL",
"U_INTERFACE.XTBL",
"VCLES.XTBL",
"VBLACKHAWK.XTBL",
"VHELI_MAD03.XTBL",
"VPONY.XTBL",
"VRIOT.XTBL",
"VTANK.XTBL",
"VVTOL.XTBL",
"VVTOL2.XTBL",
"VGAT_LS.XTBL",
"VJOSH_LS.XTBL",
"VKIA_LS.XTBL",
"VKILLBANE_LS.XTBL",
"VKINZIE_LS.XTBL",
"VMATT_LS.XTBL",
"01_LS.XTBL",
"02_LS.XTBL",
"03_LS.XTBL",
"VOLEG_LS.XTBL",
"VPHILLIPE_LS.XTBL",
"VPIERCE_LS.XTBL",
"VPLAYER_BF_LS.XTBL",
"VPLAYER_BM_LS.XTBL",
"VPLAYER_HF_LS.XTBL",
"VPLAYER_HM_LS.XTBL",
"VPLAYER_WFA_LS.XTBL",
"VPLAYER_WF_LS.XTBL",
"VPLAYER_WMA_LS.XTBL",
"VPLAYER_WM_LS.XTBL",
"VPLAYER_Z_LS.XTBL",
}
local current_frame = 0
while true do
--Update stuff only every some amount of items... fill in with random shit...
if current_frame % 20 == 0 then
local core_temp = rand_float(90,100)
core_temp = (floor(core_temp * 100)) * .01 + 1
local core_tmp_txt = "CORE TEMP\n" .. core_temp
vint_set_property(core_temp_txt_h, "text_tag", core_tmp_txt)
end
if current_frame % 4 == 0 then
local processing_txt = "PROCESSING...\n" .. process_list[rand_int(1, #process_list - 1)]
vint_set_property(processing_txt_h, "text_tag", processing_txt)
end
if current_frame % 27 == 0 then
local process_count = rand_int(89, 120)
local processes_txt = "PROCESSES\n" .. process_count
vint_set_property(processes_txt_h, "text_tag", processes_txt)
end
if current_frame % 27 == 0 then
local cpu_pct = rand_float(.1,1)
local text = 12 * cpu_pct
local text = floor(text*1000) * .001
vint_set_property(speed_txt_h, "text_tag", text)
end
if current_frame % 10 == 0 then
local right_large_fill_h = vint_object_find("right_large_fill")
local right_large_cap_h = vint_object_find("right_large_cap")
local width, height = element_get_actual_size(right_large_fill_h)
local x, y = vint_get_property(right_large_cap_h, "anchor")
width = rand_int(20, 380 * cpu_pct) -- floor(current_frame*.1)
element_set_actual_size(right_large_fill_h, width, height)
vint_set_property(right_large_cap_h, "anchor", width+7, y)
local width, height =element_get_actual_size(right_large_cap_h)
width = rand_int(2, max(3,floor(current_frame*.1)))
element_set_actual_size(right_large_cap_h, width, height)
end
if current_frame % 30 == 0 then
local text = rand_int(0, 99)
vint_set_property(core_anal_1_txt_h, "text_tag", text)
end
if current_frame % 60 == 0 then
local text = rand_int(0, 325)
vint_set_property(core_anal_2_txt_h, "text_tag", text)
end
current_frame = current_frame + 1
if current_frame == 1000 then
current_frame = 0
end
thread_yield()
end
end