./vint_bugs.lua

  1. R_meter = 0 
  2. local Respect_level 	= 0 
  3. local Respect_pct 	= 0 
  4. local Respect_total 	= 0  
  5. local RESPECT_PER_LEVEL = 7000 
  6.  
  7. local Input_tracker 
  8. Bugs_mouse_Input_tracker = -1 
  9.  
  10.  
  11. local LIST_SIZE = 400 
  12. local LIST_ITEMS = 10 
  13. local LIST_SCALE = .8 
  14. Bugs_megalist = {} 
  15. List_data = {} 
  16.  
  17. local Text_grp_1_h = -1 
  18. local Text_grp_2_h = -1 
  19. local Text_grp_3_h = -1 
  20.  
  21.  
  22. function vint_bugs_init() 
  23.  
  24. 	local Header_mini_obj = Vdo_pause_header_mini:new("header_mini") 
  25. 	--Header_mini_obj:set_text("IM FRESH") 
  26. 	Header_mini_obj:set_text("IM FRESH OHHHHHH SO FRESH") 
  27. 	vint_set_property(Header_mini_obj.handle, "alpha", .5) 
  28. 	 
  29. 	 
  30. 	local doc_h = vint_document_find("vint_bugs") 
  31. 	debug_print("vint", "doc_h" .. doc_h .. "\n") 
  32. 	R_meter = Vdo_respect_meter:new("r_object", 0, 0, "vint_bugs.lua", "R_meter") 
  33. 	Respect_level = 0 
  34. 	Respect_pct = 0 
  35. 	Respect_total = 0  
  36. 	r_update_respect() 
  37. 	 
  38. 	for i = 1, 20 do 
  39. 		List_data[i] = {id = i, 	type = TYPE_BUTTON, label = "MENU ITEM " .. i, is_new = true} 
  40. 	end 
  41. 	 
  42. 	Bugs_megalist = Vdo_mega_list:new("bugs_megalist", 0, doc_h, "vint_bugs.lua", "Bugs_megalist") 
  43. 	Bugs_megalist:set_highlight_color(COLOR_CHEATS_PRIMARY, COLOR_CHEATS_SECONDARY)	 
  44. 	Bugs_megalist:draw_items(List_data, 1, LIST_SIZE, LIST_ITEMS, LIST_FONT_SCALE, false) 
  45.  
  46. 	Input_tracker =  Vdo_input_tracker:new() 
  47. 	Input_tracker:add_input("select", "r_add_respect", 50) 
  48. 	Input_tracker:add_input("back", "r_remove_respect", 50) 
  49. 	Input_tracker:add_input("nav_up", "megalist_nav_up", 50) 
  50. 	Input_tracker:add_input("nav_down", "megalist_nav_down", 50) 
  51. 	Input_tracker:add_input("alt_select", "r_add_respect_double", 50) 
  52. 	Input_tracker:add_input("exit", "r_remove_respect_double", 50) 
  53. 	Input_tracker:subscribe(true) 
  54. 	 
  55. 	if game_get_platform() == "PC" then 
  56. 		Bugs_mouse_Input_tracker = Vdo_input_tracker:new() 
  57. 		Bugs_megalist:add_mouse_inputs("vint_bugs", Bugs_mouse_Input_tracker) 
  58. 		Bugs_mouse_Input_tracker:subscribe(true) 
  59. 		debug_print("vint", "HELLO: " .. var_to_string(Bugs_mouse_Input_tracker) .. "\n") 
  60. 	end 
  61. 	 
  62. 	Text_grp_1_h = vint_object_find("text_grp_1") 
  63. 	local text_1_h = vint_object_find("text_1_txt", Text_grp_1_h) 
  64. 	local text_1_bg_h = vint_object_find("text_1_bg") 
  65. 	local width, height = element_get_actual_size(text_1_h) 
  66. 	element_set_actual_size(text_1_bg_h, width, height) 
  67. 	 
  68. 	Text_grp_2_h = vint_object_find("text_grp_2") 
  69. 	local text_2_h = vint_object_find("text_2_txt", Text_grp_2_h) 
  70. 	local text_2_bg_h = vint_object_find("text_2_bg") 
  71. 	local width, height = element_get_actual_size(text_2_h) 
  72. 	element_set_actual_size(text_2_bg_h, width, height) 
  73. 	 
  74. 	Text_grp_3_h = vint_object_find("text_grp_3") 
  75. 	local text_3_h = vint_object_find("text_3_txt", Text_grp_3_h) 
  76. 	local text_3_bg_h = vint_object_find("text_3_bg") 
  77. 	local width, height = element_get_actual_size(text_3_h) 
  78. 	element_set_actual_size(text_3_bg_h, width, height) 
  79. 	 
  80. 	vint_set_glitch_preset( "falling_skies" ) 
  81. 	vint_set_glitch_percent( 1.0 ) 
  82.  
  83. 	local test_image = vint_object_find( "glitch_img" )	 
  84. 	glitched_object_add( test_image ) 
  85. end 
  86.  
  87. function vint_bugs_cleanup() 
  88. 	Input_tracker:subscribe(false) 
  89. 	Input_tracker:remove_all() 
  90. 	 
  91. 	vint_set_glitch_preset("hub") 
  92. 	vint_spike_glitch(0, 0) 
  93. end 
  94.  
  95. ------------------------------------------------------------------------------- 
  96. -- Mouse Inputs 
  97. --  
  98. function vint_bugs_mouse_click(event, target_handle) 
  99. 	-- If the target_handle matches a button, activate it 
  100. 	local new_index = Bugs_megalist:get_button_index(target_handle) 
  101. 	if new_index ~= 0 then 
  102. 		-- Enter an option if the target_handle is in the List 
  103. 		Bugs_megalist:set_selection(new_index) 
  104. 		--Click event? 
  105. 	end 
  106. end 
  107.  
  108. function vint_bugs_mouse_move(event, target_handle) 
  109. 	local new_index = Bugs_megalist:get_button_index(target_handle) 
  110. 	if new_index ~= 0 then 
  111. 		-- Set the button as the new selected highlight 
  112. 		Bugs_megalist:set_selection(new_index) 
  113.  
  114. 		local current_data = Bugs_megalist:return_selected_data() 
  115.  
  116. 		debug_print("vint", "new_index:"	.. new_index .. "\n") 
  117. 		Bugs_megalist:move_cursor(0, true) 
  118. 		if current_data.is_new then 
  119. 			Bugs_mouse_Input_tracker:remove_all() 
  120. 			Bugs_megalist:remove_new_flag(new_index) 
  121. 			Bugs_megalist:move_cursor(0, true) 
  122. 			 
  123. 			--Re add inputs... 
  124. 			if game_get_platform() == "PC" then 
  125. 				Bugs_mouse_Input_tracker:remove_all() 
  126. 				Bugs_megalist:add_mouse_inputs("vint_bugs", Bugs_mouse_Input_tracker) 
  127. 				Bugs_mouse_Input_tracker:subscribe(true) 
  128. 			end 
  129. 			 
  130. 			 
  131. 		end 
  132. 		 
  133.  
  134. 	end	 
  135. end 
  136.  
  137. function vint_bugs_mouse_scroll(event, target_handle, mouse_x, mouse_y, scroll_lines) 
  138. 	if scroll_lines ~= 0 then 
  139. 		if Bugs_megalist:get_scroll_region_handle() == target_handle then 
  140. 			Bugs_megalist:scroll_list(scroll_lines * -1) 
  141. 			Bugs_megalist:update_mouse_inputs("vint_bugs", Bugs_mouse_Input_tracker) 
  142. 		end 
  143. 	end 
  144. end 
  145.  
  146. function vint_bugs_mouse_drag(event, target_handle, mouse_x, mouse_y) 
  147. 	if Bugs_megalist.scrollbar.tab_grp.handle == target_handle then 
  148. 		local new_start_index = Bugs_megalist.scrollbar:drag_scrolltab(mouse_y, Bugs_megalist.num_buttons - (Bugs_megalist.max_buttons - 1)) 
  149. 		Bugs_megalist:scroll_list(0, new_start_index) 
  150. 	end 
  151. end 
  152.  
  153. function vint_bugs_mouse_drag_release(event, target_handle, mouse_x, mouse_y) 
  154. 	if Bugs_megalist.scrollbar.tab_grp.handle == target_handle then 
  155. 		local start_index = Bugs_megalist:get_visible_indices() 
  156. 		Bugs_megalist.scrollbar:release_scrolltab(start_index, Bugs_megalist.num_buttons - (Bugs_megalist.max_buttons - 1)) 
  157. 		Bugs_megalist:update_mouse_inputs("vint_bugs", Bugs_mouse_Input_tracker) 
  158. 	end 
  159. end 
  160.  
  161.  
  162. function r_update_respect() 
  163. 	 
  164. 	R_meter:update_respect(Respect_total, Respect_pct, Respect_level, Show_upgrade) 
  165. 	debug_print("vint", "Respect_total: " .. var_to_string(Respect_total) .. "\n") 
  166. 	debug_print("vint", "Respect_pct: " .. var_to_string(Respect_pct) .. "\n") 
  167. 	debug_print("vint", "Respect_level: " .. var_to_string(Respect_level) .. "\n") 
  168. 	debug_print("vint", "SHOW UPGRADE: " .. var_to_string(Show_upgrade) .. "\n") 
  169. end 
  170.  
  171.  
  172. Show_upgrade = false 
  173. Show_upgrade_thread = 0 
  174.  
  175. function show_upgrade_func() 
  176. 	thread_yield(3) 
  177. 	Show_upgrade = false 
  178. 	R_meter:game_is_finished_showing_upgrades() 
  179. 	r_update_respect() 
  180. 	Show_upgrade_thread = 0 
  181. end 
  182.  
  183. function respect_total_update(respect) 
  184. 	Respect_total = Respect_total + respect 
  185. 	 
  186. 	if Respect_total > 400000 or Respect_total < 0 then 
  187. 		Respect_total = 1 
  188. 		debug_print("vint", "RELOAD DOC!! reset\n") 
  189. 	end 
  190. 	local current_level = Respect_level 
  191. 	 
  192. 	Respect_level = floor(Respect_total / RESPECT_PER_LEVEL) 
  193. 	 
  194.  
  195. 	if current_level < Respect_level then 
  196. 		if Show_upgrade_thread == 0 then 
  197. 			Show_upgrade = true 
  198. 			Show_upgrade_thread = thread_new("show_upgrade_func") 
  199. 		end 
  200. 	end 
  201.  
  202. 	Respect_pct = (Respect_total % RESPECT_PER_LEVEL) / RESPECT_PER_LEVEL 
  203. end 
  204.  
  205.  
  206. function r_add_respect()  
  207. 	respect_total_update(1000) 
  208. 	r_update_respect() 
  209. end 
  210. function r_add_respect_double()  
  211. 	respect_total_update(4000) 
  212. 	r_update_respect() 
  213. end 
  214.  
  215. function r_remove_respect() 
  216. 	respect_total_update(-1000) 
  217. 	r_update_respect() 
  218. end 
  219. function r_remove_respect_double() 
  220. 	respect_total_update(-4000) 
  221. 	r_update_respect() 
  222. end 
  223.  
  224. function megalist_nav_up() 
  225. 	Bugs_megalist:move_cursor(-1) 
  226. end 
  227. function megalist_nav_down() 
  228. 	Bugs_megalist:move_cursor(1) 
  229. end 
  230.  
  231. function test_numbers() 
  232. 	local text_field_h = vint_object_find("text_field") 
  233. 	vint_set_property(text_field_h, "font", "header_n") 
  234. 	for i = 1000, 2000 do 
  235. 		vint_set_property(text_field_h, "text_tag", i) 
  236. 		thread_yield() 
  237. 	end 
  238. end 
  239.  
  240. function test_numbers_commas() 
  241. 	local text_field_h = vint_object_find("text_field") 
  242. 	vint_set_property(text_field_h, "font", "header_n") 
  243. 	local do_test = true 
  244. 	local value = 0 
  245. 	while do_test do 
  246. 		value = value + rand_int(60,99) 
  247. 		local formated_value = format_cash(value) 
  248. 		vint_set_property(text_field_h, "text_tag", "$" .. formated_value) 
  249. 		thread_yield() 
  250. 		if value > 40000 then 
  251. 			do_test = false 
  252. 		end 
  253. 	end 
  254. end 
  255.  
  256. function test_numbers_periods() 
  257. 	local text_field_h = vint_object_find("text_field") 
  258. 	 
  259. 	local do_test = true 
  260. 	local value_1 = 0 
  261. 	local value_2 = 0 
  262. 	local value_3 = 0 
  263. 	while do_test do 
  264. 		value_1 = value_1 + rand_int(1,99) 
  265. 		value_2 = value_2 + rand_int(1,99) 
  266. 		value_3 = value_3 + rand_int(1,99) 
  267. 		local formated_value = "$" .. value_1 .. "." .. value_2 .. "." .. value_2 
  268. 		vint_set_property(text_field_h, "text_tag", formated_value) 
  269. 		thread_yield() 
  270. 		if value_1 + value_2 + value_3 > 100000 then 
  271. 			do_test = false 
  272. 		end 
  273. 	end 
  274. end 
  275.  
  276. function test_timer() 
  277. 	local text_field_h = vint_object_find("text_field") 
  278. 	vint_set_property(text_field_h, "font", "header_n") 
  279. 	 
  280. 	local do_test = true 
  281. 	local value = 0 
  282. 	while do_test do 
  283. 		value = value + 1 
  284. 		local formated_value = format_clock(value) 
  285. 		vint_set_property(text_field_h, "text_tag", formated_value) 
  286. 		thread_yield() 
  287. 		if value > 3000 then 
  288. 			do_test = false 
  289. 		end 
  290. 	end 
  291. end