R_meter = 0
local Respect_level = 0
local Respect_pct = 0
local Respect_total = 0
local RESPECT_PER_LEVEL = 7000
local Input_tracker
Bugs_mouse_Input_tracker = -1
local LIST_SIZE = 400
local LIST_ITEMS = 10
local LIST_SCALE = .8
Bugs_megalist = {}
List_data = {}
local Text_grp_1_h = -1
local Text_grp_2_h = -1
local Text_grp_3_h = -1
function vint_bugs_init()
local Header_mini_obj = Vdo_pause_header_mini:new("header_mini")
--Header_mini_obj:set_text("IM FRESH")
Header_mini_obj:set_text("IM FRESH OHHHHHH SO FRESH")
vint_set_property(Header_mini_obj.handle, "alpha", .5)
local doc_h = vint_document_find("vint_bugs")
debug_print("vint", "doc_h" .. doc_h .. "\n")
R_meter = Vdo_respect_meter:new("r_object", 0, 0, "vint_bugs.lua", "R_meter")
Respect_level = 0
Respect_pct = 0
Respect_total = 0
r_update_respect()
for i = 1, 20 do
List_data[i] = {id = i, type = TYPE_BUTTON, label = "MENU ITEM " .. i, is_new = true}
end
Bugs_megalist = Vdo_mega_list:new("bugs_megalist", 0, doc_h, "vint_bugs.lua", "Bugs_megalist")
Bugs_megalist:set_highlight_color(COLOR_CHEATS_PRIMARY, COLOR_CHEATS_SECONDARY)
Bugs_megalist:draw_items(List_data, 1, LIST_SIZE, LIST_ITEMS, LIST_FONT_SCALE, false)
Input_tracker = Vdo_input_tracker:new()
Input_tracker:add_input("select", "r_add_respect", 50)
Input_tracker:add_input("back", "r_remove_respect", 50)
Input_tracker:add_input("nav_up", "megalist_nav_up", 50)
Input_tracker:add_input("nav_down", "megalist_nav_down", 50)
Input_tracker:add_input("alt_select", "r_add_respect_double", 50)
Input_tracker:add_input("exit", "r_remove_respect_double", 50)
Input_tracker:subscribe(true)
if game_get_platform() == "PC" then
Bugs_mouse_Input_tracker = Vdo_input_tracker:new()
Bugs_megalist:add_mouse_inputs("vint_bugs", Bugs_mouse_Input_tracker)
Bugs_mouse_Input_tracker:subscribe(true)
debug_print("vint", "HELLO: " .. var_to_string(Bugs_mouse_Input_tracker) .. "\n")
end
Text_grp_1_h = vint_object_find("text_grp_1")
local text_1_h = vint_object_find("text_1_txt", Text_grp_1_h)
local text_1_bg_h = vint_object_find("text_1_bg")
local width, height = element_get_actual_size(text_1_h)
element_set_actual_size(text_1_bg_h, width, height)
Text_grp_2_h = vint_object_find("text_grp_2")
local text_2_h = vint_object_find("text_2_txt", Text_grp_2_h)
local text_2_bg_h = vint_object_find("text_2_bg")
local width, height = element_get_actual_size(text_2_h)
element_set_actual_size(text_2_bg_h, width, height)
Text_grp_3_h = vint_object_find("text_grp_3")
local text_3_h = vint_object_find("text_3_txt", Text_grp_3_h)
local text_3_bg_h = vint_object_find("text_3_bg")
local width, height = element_get_actual_size(text_3_h)
element_set_actual_size(text_3_bg_h, width, height)
vint_set_glitch_preset( "falling_skies" )
vint_set_glitch_percent( 1.0 )
local test_image = vint_object_find( "glitch_img" )
glitched_object_add( test_image )
end
function vint_bugs_cleanup()
Input_tracker:subscribe(false)
Input_tracker:remove_all()
vint_set_glitch_preset("hub")
vint_spike_glitch(0, 0)
end
-------------------------------------------------------------------------------
-- Mouse Inputs
--
function vint_bugs_mouse_click(event, target_handle)
-- If the target_handle matches a button, activate it
local new_index = Bugs_megalist:get_button_index(target_handle)
if new_index ~= 0 then
-- Enter an option if the target_handle is in the List
Bugs_megalist:set_selection(new_index)
--Click event?
end
end
function vint_bugs_mouse_move(event, target_handle)
local new_index = Bugs_megalist:get_button_index(target_handle)
if new_index ~= 0 then
-- Set the button as the new selected highlight
Bugs_megalist:set_selection(new_index)
local current_data = Bugs_megalist:return_selected_data()
debug_print("vint", "new_index:" .. new_index .. "\n")
Bugs_megalist:move_cursor(0, true)
if current_data.is_new then
Bugs_mouse_Input_tracker:remove_all()
Bugs_megalist:remove_new_flag(new_index)
Bugs_megalist:move_cursor(0, true)
--Re add inputs...
if game_get_platform() == "PC" then
Bugs_mouse_Input_tracker:remove_all()
Bugs_megalist:add_mouse_inputs("vint_bugs", Bugs_mouse_Input_tracker)
Bugs_mouse_Input_tracker:subscribe(true)
end
end
end
end
function vint_bugs_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines)
if scroll_lines ~= 0 then
if Bugs_megalist:get_scroll_region_handle() == target_handle then
Bugs_megalist:scroll_list(scroll_lines * -1)
Bugs_megalist:update_mouse_inputs("vint_bugs", Bugs_mouse_Input_tracker)
end
end
end
function vint_bugs_mouse_drag(event, target_handle, mouse_x, mouse_y)
if Bugs_megalist.scrollbar.tab_grp.handle == target_handle then
local new_start_index = Bugs_megalist.scrollbar:drag_scrolltab(mouse_y, Bugs_megalist.num_buttons - (Bugs_megalist.max_buttons - 1))
Bugs_megalist:scroll_list(0, new_start_index)
end
end
function vint_bugs_mouse_drag_release(event, target_handle, mouse_x, mouse_y)
if Bugs_megalist.scrollbar.tab_grp.handle == target_handle then
local start_index = Bugs_megalist:get_visible_indices()
Bugs_megalist.scrollbar:release_scrolltab(start_index, Bugs_megalist.num_buttons - (Bugs_megalist.max_buttons - 1))
Bugs_megalist:update_mouse_inputs("vint_bugs", Bugs_mouse_Input_tracker)
end
end
function r_update_respect()
R_meter:update_respect(Respect_total, Respect_pct, Respect_level, Show_upgrade)
debug_print("vint", "Respect_total: " .. var_to_string(Respect_total) .. "\n")
debug_print("vint", "Respect_pct: " .. var_to_string(Respect_pct) .. "\n")
debug_print("vint", "Respect_level: " .. var_to_string(Respect_level) .. "\n")
debug_print("vint", "SHOW UPGRADE: " .. var_to_string(Show_upgrade) .. "\n")
end
Show_upgrade = false
Show_upgrade_thread = 0
function show_upgrade_func()
thread_yield(3)
Show_upgrade = false
R_meter:game_is_finished_showing_upgrades()
r_update_respect()
Show_upgrade_thread = 0
end
function respect_total_update(respect)
Respect_total = Respect_total + respect
if Respect_total > 400000 or Respect_total < 0 then
Respect_total = 1
debug_print("vint", "RELOAD DOC!! reset\n")
end
local current_level = Respect_level
Respect_level = floor(Respect_total / RESPECT_PER_LEVEL)
if current_level < Respect_level then
if Show_upgrade_thread == 0 then
Show_upgrade = true
Show_upgrade_thread = thread_new("show_upgrade_func")
end
end
Respect_pct = (Respect_total % RESPECT_PER_LEVEL) / RESPECT_PER_LEVEL
end
function r_add_respect()
respect_total_update(1000)
r_update_respect()
end
function r_add_respect_double()
respect_total_update(4000)
r_update_respect()
end
function r_remove_respect()
respect_total_update(-1000)
r_update_respect()
end
function r_remove_respect_double()
respect_total_update(-4000)
r_update_respect()
end
function megalist_nav_up()
Bugs_megalist:move_cursor(-1)
end
function megalist_nav_down()
Bugs_megalist:move_cursor(1)
end
function test_numbers()
local text_field_h = vint_object_find("text_field")
vint_set_property(text_field_h, "font", "header_n")
for i = 1000, 2000 do
vint_set_property(text_field_h, "text_tag", i)
thread_yield()
end
end
function test_numbers_commas()
local text_field_h = vint_object_find("text_field")
vint_set_property(text_field_h, "font", "header_n")
local do_test = true
local value = 0
while do_test do
value = value + rand_int(60,99)
local formated_value = format_cash(value)
vint_set_property(text_field_h, "text_tag", "$" .. formated_value)
thread_yield()
if value > 40000 then
do_test = false
end
end
end
function test_numbers_periods()
local text_field_h = vint_object_find("text_field")
local do_test = true
local value_1 = 0
local value_2 = 0
local value_3 = 0
while do_test do
value_1 = value_1 + rand_int(1,99)
value_2 = value_2 + rand_int(1,99)
value_3 = value_3 + rand_int(1,99)
local formated_value = "$" .. value_1 .. "." .. value_2 .. "." .. value_2
vint_set_property(text_field_h, "text_tag", formated_value)
thread_yield()
if value_1 + value_2 + value_3 > 100000 then
do_test = false
end
end
end
function test_timer()
local text_field_h = vint_object_find("text_field")
vint_set_property(text_field_h, "font", "header_n")
local do_test = true
local value = 0
while do_test do
value = value + 1
local formated_value = format_clock(value)
vint_set_property(text_field_h, "text_tag", formated_value)
thread_yield()
if value > 3000 then
do_test = false
end
end
end