./store_crib_cash.lua

  1. --[[ 
  2. CRIB_CASH_TRANSFER_FROM_BANK 
  3. CRIB_CASH_PLAYER_CASH 
  4. CRIB_CASH_INCOME						==INCOME PER DAY 
  5. CRIB_CASH_TRANSFER_CAP				==TRANSFER CAP 
  6. CRIB_CASH_READY						==Ready 
  7. CRIB_CASH_TRANSFER					==Transfering 
  8. CRIB_CASH_TRANSFER_COMPLETE		==TRANSFER COMPLETE 
  9. CRIB_CASH_DO_TRANSFER				==TRANSFER 
  10. CRIB_CASH_DO_CONTINUE				==CONTINUE 
  11. ]] 
  12.  
  13. STORE_CRIB_CASH_MAX_PERCENT = 340 
  14. STORE_CRIB_CIRCLE_MAX = 6.28 -- 2pi 
  15. STORE_CRIB_CASH_GRAPH_SPACER = 0.025 
  16.  
  17. --Graph section enums 
  18. STORE_CRIB_CASH_ACTIVITIES			= 0 
  19. STORE_CRIB_CASH_TARGETS 			= 1 
  20. --STORE_CRIB_CASH_FIREWALLS 			= 2 -- Firewalls were removed but leaving this here to help explain the hackyness in store_crib_category_populate() 
  21. STORE_CRIB_CASH_STORE_HACKING		= 2  
  22. STORE_CRIB_CASH_BONUS				= 3 
  23.  
  24. local Cache_graph_data = { 
  25. 	total_cache_earned = 2000, 
  26. 	[STORE_CRIB_CASH_ACTIVITIES] = { 
  27. 		label = "PAUSE_MAP_FILTER_ACTIVITIES", 
  28. 		total_items = 50, 
  29. 		owned_items = 20, 
  30. 		cache_earned = 1000,	 
  31. 		val_txt = "activities_val_txt",		 
  32. 		title_txt ="activities_title_txt", 
  33. 		grp = "activities_grp",			 
  34. 		rotation_grp = "activities_rot_grp", 
  35. 		circle = "cache_meter_activities", 
  36. 		twn = "activities_circle_twn", 
  37. 		tint = {R = 0, G = 101/255, B = 153/255}, 
  38. 	}, 
  39. 	 
  40. 	[STORE_CRIB_CASH_TARGETS] = { 
  41. 		label = "PAUSE_MAP_FILTER_DIVERSIONS", 
  42. 		total_items = 50, 
  43. 		owned_items = 15, 
  44. 		cache_earned = 500,	 
  45. 		val_txt = "targets_val_txt",		 
  46. 		title_txt = "targets_title_txt", 
  47. 		grp = "targets_grp",	 
  48. 		rotation_grp = "targets_rot_grp", 
  49. 		circle = "cache_meter_targets", 
  50. 		twn = "targets_circle_twn", 
  51. 		tint = {R = 165/255, G = 16/255, B = 21/255}, 
  52. 	}, 
  53. 	 
  54. 	--[[[STORE_CRIB_CASH_FIREWALLS] = { -- Firewalls were removed but leaving this here to help explain the hackyness in store_crib_category_populate() 
  55. 		label = "FIREWALLS", 
  56. 		total_items = 20, 
  57. 		owned_items = 0, 
  58. 		cache_earned = 0,	 
  59. 		val_txt = "firewalls_val_txt",		 
  60. 		title_txt = "firewalls_title_txt", 
  61. 		grp = "firewalls_grp",		 
  62. 		rotation_grp = "firewalls_rot_grp", 
  63. 		circle = "cache_meter_firewalls", 
  64. 		twn = "firewalls_circle_twn", 
  65. 		tint = {R = 148/255, G = 0/255, B = 197/255}, 
  66. 	}, ]]-- 
  67. 	 
  68. 	[STORE_CRIB_CASH_STORE_HACKING] = { 
  69. 		label = "HACKING_TITLE", 
  70. 		total_items = 20, 
  71. 		owned_items = 10, 
  72. 		cache_earned = 500,	 
  73. 		val_txt = "store_hacking_val_txt",		 
  74. 		title_txt = "store_hacking_title_txt", 
  75. 		grp = "store_hacking_grp",		 
  76. 		rotation_grp = "store_hacking_rot_grp", 
  77. 		circle = "cache_meter_store_hacking", 
  78. 		twn = "store_hacking_circle_twn", 
  79. 		tint = {R = 150/255, G = 194/255, B = 70/255}, 
  80. 	}, 
  81.  
  82. 	[STORE_CRIB_CASH_BONUS] = { 
  83. 		label = "MENU_CACHE", --"HUB_CACHE_BONUS", 
  84. 		total_items = 20, 
  85. 		owned_items = 10, 
  86. 		cache_earned = 0,	 
  87. 		val_txt = "bonus_val_txt",		 
  88. 		title_txt = "bonus_title_txt", 
  89. 		grp = "bonus_grp",		 
  90. 		rotation_grp = "bonus_rot_grp", 
  91. 		circle = "cache_meter_bonus", 
  92. 		twn = "bonus_circle_twn", 
  93. 		tint = {R = 220/255, G = 148/255, B = 29/255}, 
  94. 	}, 
  95. } 
  96.  
  97. --Globals... 
  98. local Hint_bar 
  99. local Input_tracker 
  100. local Crib_cash_mouse_input_tracker 
  101.  
  102. local Bg_image 
  103.  
  104. local Crib_cash_data = {} 
  105.  
  106. local Store_crib_cash_doc_h = -1 
  107.  
  108. local CRIB_CASH_SUCCESS	= 0 
  109. local CRIB_CASH_WARNING = 1 
  110.  
  111. --Screen states... 
  112. local CRIB_CASH_SCREEN_STATE_PRE_TRANSFER 	= 0 
  113. local CRIB_CASH_SCREEN_STATE_TRANSFERING	 	= 1  
  114. local CRIB_CASH_SCREEN_STATE_POST_TRANSFER 	= 2 
  115.  
  116. local Crib_cash_screen_state = CRIB_CASH_SCREEN_STATE_PRE_TRANSFER		 --Set current screen state... 
  117.  
  118. -- Flag to block input to prevent skipping through the screen too quickly 
  119. local Store_crib_cash_input_is_blocked = false 
  120.  
  121. -- Thread to delay input 
  122. local Store_crib_cash_input_delay_thread = -1 
  123.  
  124. function store_crib_cash_init() 
  125. 	local Store_crib_cash_doc_h = vint_document_find("store_crib_cash") 
  126.  
  127. 	--Hide screen grp 
  128. 	local screen_grp_h = vint_object_find("screen_grp") 
  129. 	vint_set_property(screen_grp_h, "alpha", 0) 
  130. 	 
  131. 	--Populate hint bar... 
  132. 	local hints = {{CTRL_MENU_BUTTON_A, "PAUSE_MENU_ACCEPT"}} 
  133. 	Hint_bar = Vdo_hint_bar:new("hint_bar") 
  134. 	Hint_bar:set_hints(hints) 
  135. 	Hint_bar:set_alpha(0) 
  136.  
  137. 	Input_tracker = Vdo_input_tracker:new() 
  138. 	Input_tracker:add_input("select", "store_crib_input", 50) 
  139. 	Input_tracker:add_input("map", "store_crib_cash_nav_map", 50) 
  140. 	Input_tracker:add_input("back", "store_crib_input", 50) 
  141. 	Input_tracker:add_input("all_unassigned", "store_crib_input", 50) 
  142. 	Input_tracker:subscribe(true) 
  143. 	 
  144. 	--Initialize mouse inputs 
  145. 	if game_get_platform() == "PC" then 
  146. 		Crib_cash_mouse_input_tracker = Vdo_input_tracker:new() 
  147. 		Hint_bar:add_mouse_inputs("store_crib_cash", Crib_cash_mouse_input_tracker) 
  148. 		 
  149. 		Bg_image = Vdo_base_object:new("store_crib_cash_background_bmp", 0, Store_crib_cash_doc_h) 
  150. 		Crib_cash_mouse_input_tracker:add_mouse_input("mouse_move", "store_crib_cash_mouse_move", 0, Bg_image.handle) 
  151. 		Crib_cash_mouse_input_tracker:add_mouse_input("mouse_click", "store_crib_cash_mouse_click", 0, Bg_image.handle) 
  152. 		 
  153. 		Crib_cash_mouse_input_tracker:subscribe(true) 
  154. 	end 
  155. 	 
  156. 	--Fake populate... (should be done with dataresponder) ... 
  157. 	--store_crib_cash_populate(50000,50000,1500,5000) 
  158. 	vint_dataresponder_request("store_crib_cash_request_data", "store_crib_cash_populate", 0) 
  159. 	vint_dataresponder_request("store_crib_cash_request_data", "store_crib_category_populate", 0, "per_category") 
  160. 	 
  161. 	--Hide complete popup 
  162. 	local popup_grp_h = vint_object_find("popup_grp") 
  163. 	vint_set_property(popup_grp_h, "alpha", 0) 
  164. 	 
  165. 	--Hide meter until needed 
  166. 	local meter_grp_h = vint_object_find("meter_grp", 0, Store_crib_cash_doc_h) 
  167. 	vint_set_property(meter_grp_h, "alpha", 0) 
  168. 	 
  169. 	--Set up title	 
  170. 	local cell_title_h = Vdo_cell_title:new("cell_title", 0, Store_crib_cash_doc_h) 
  171. 	cell_title_h:set_text("COMPLETION_CASH") 
  172. 	cell_title_h:set_icon("ui_cell_icon_cash") 
  173. 	cell_title_h:play_dots_anim() 
  174. 	 
  175. 	--Setup pie chart tweens and hide elements for now 
  176. 	store_crib_cash_set_graph_values()	 
  177. 	 
  178. 	--If no money to transfer (early in the game) show informative popup 
  179. 	if Crib_cash_data.cash_from_bank <= 0 and Crib_cash_data.daily_cash == 0 then 
  180. 		store_crib_cash_popup()		 
  181. 	else 
  182. 		local trans_in_event_twn_h = vint_object_find("cell_fade_wait") 
  183. 		vint_set_property(trans_in_event_twn_h,"end_event","store_crib_cash_cb") 
  184. 	end 
  185. 	 
  186. 	--Transition screen in 
  187. 	cell_transition_screen(CELL_STATE_PORTRAIT, CELL_SCREEN_CASH, CELL_SCREEN_MAIN, store_crib_cash_nothing)	 
  188. 	 
  189. 	--Glitch screen in 
  190. 	--glitch_cell() 
  191. end 
  192.  
  193.  
  194. function store_crib_cash_nothing() 
  195. end 
  196.  
  197.  
  198. function store_crib_cash_cleanup() 
  199. 	Input_tracker:subscribe(false) 
  200. 	Input_tracker:remove_all() 
  201. 	if game_get_platform() == "PC" then 
  202. 		Crib_cash_mouse_input_tracker:subscribe(false) 
  203. 		Crib_cash_mouse_input_tracker:remove_all() 
  204. 	end 
  205. end 
  206.  
  207.  
  208. function store_crib_cash_cb(tween_h) 
  209. 	--Do transfer... 
  210. 	crib_get_cash_stash() -- C function call 
  211. 	 
  212. 	thread_new("store_crib_cash_transfer")	 
  213. end 
  214.  
  215.  
  216. --Show informational popup on how to increase income 
  217. function store_crib_cash_popup() 
  218. 	local cell_content_grp_h = vint_object_find("cell_content_grp") 
  219. 	vint_set_property(cell_content_grp_h, "visible", false) 
  220.  
  221. 	local popup_anim_h = vint_object_find("popup_anim") 
  222. 	lua_play_anim(popup_anim_h, 0) 
  223. 	 
  224. 	Crib_cash_screen_state = CRIB_CASH_SCREEN_STATE_POST_TRANSFER	 
  225. 	 
  226. 	local meter_clip_h = vint_object_find("popup_meter_clip")	 
  227. 	local meter_fill_img_h = vint_object_find("popup_meter_fill_img")	 
  228. 	local meter_clip_width, meter_clip_height = vint_get_property(meter_clip_h, "clip_size")	 
  229. 	local METER_MAX = 100 
  230. 	local meter_pct = 1 - Crib_cash_data.next_transfer_percent 
  231. 	 
  232. 	local new_value = meter_pct * METER_MAX 
  233. 	 
  234. 	local incriment = METER_MAX/16 
  235. 		 
  236. 	for i = 0, METER_MAX, incriment do 
  237. 		if new_value >= i and new_value < (i + incriment) then 
  238. 			new_value = i 
  239. 		end 
  240. 	end 
  241. 	 
  242. 	--Tint meter white 
  243. 	vint_set_property(meter_fill_img_h, "tint", 220/255, 220/255, 220/255) 
  244. 	 
  245. 	--Set meter clip size 
  246. 	vint_set_property(meter_clip_h, "clip_size", new_value, meter_clip_height)		 
  247. end 
  248.  
  249.  
  250. ------------------------------------------------------------------------------- 
  251. -- Called by C++ via data responder 
  252. -- 
  253. -- cash_from_bank		how much the bank is paying the player 
  254. -- player_cash			how much cash the player has before withdrawl 
  255. --	daily_cash			how much cash the player earns per day... 
  256. -- transfer_cap		How much cash the bank can max out on. 
  257. ------------------------------------------------------------------------------- 
  258. function store_crib_cash_populate(cash_from_bank, player_cash, daily_cash, transfer_cap, next_transfer_percent, cat_activity, cat_target, cat_diversion, cat_store, cat_bonus) 
  259. 	 
  260. 	local bank_val_txt_h 			= vint_object_find("bank_val_txt") 
  261. 	local player_cash_val_txt_h 	= vint_object_find("player_cash_val_txt") 
  262. 	local perday_val_txt_h 			= vint_object_find("perday_val_txt") 
  263. 	local transfer_cap_val_txt_h 	= vint_object_find("transfer_cap_val_txt") 
  264. 		 
  265. 	vint_set_property(bank_val_txt_h, "text_tag", "{GAME_CASH}" .. format_cash(cash_from_bank)) 
  266. 	vint_set_property(player_cash_val_txt_h, "text_tag", "{GAME_CASH}" .. format_cash(player_cash)) 
  267. 	vint_set_property(perday_val_txt_h, "text_tag", "{GAME_CASH}" .. format_cash(daily_cash)) 
  268. 	vint_set_property(transfer_cap_val_txt_h, "text_tag", "{GAME_CASH}" .. format_cash(transfer_cap)) 
  269. 	 
  270. 	--Store off to process later... 
  271. 	Crib_cash_data = { 
  272. 		cash_from_bank	= cash_from_bank, 
  273. 		player_cash = player_cash,  
  274. 		daily_cash = daily_cash,   
  275. 		transfer_cap = transfer_cap, 
  276. 		next_transfer_percent = next_transfer_percent, 
  277. 	} 
  278. 	 
  279. 	if cash_from_bank > 0 then	 
  280. 	 
  281. 		--Transferring money, play animation		 
  282. 		local transfer_anim_h = vint_object_find("transfer_anim") 
  283. 		 
  284. 		--Pulse hints when done 
  285. 		local transfer_event_twn_h = vint_object_find("transfer_event_twn", transfer_anim_h) 
  286. 		vint_set_property(transfer_event_twn_h, "end_event", "store_crib_cash_pulse_hint") 
  287. 		 
  288. 		lua_play_anim(transfer_anim_h, 0) 
  289. 		ui_audio_post_event("ui_cache_transfer") 
  290. 	else			 
  291. 	 
  292. 		store_crib_cash_popup() 
  293. 		 
  294. 		local hints = {{CTRL_MENU_BUTTON_B, "CONTROL_BACK"}} 
  295. 		Hint_bar:set_hints(hints) 
  296. 		 
  297. 		if game_get_platform() == "PC" then 
  298. 			Crib_cash_mouse_input_tracker = Vdo_input_tracker:new() 
  299. 			Hint_bar:add_mouse_inputs("store_crib_cash", Crib_cash_mouse_input_tracker) 
  300. 			Crib_cash_mouse_input_tracker:subscribe(true) 
  301. 		end 
  302. 	end 
  303. 	 
  304. 	Cache_graph_data.total_cache_earned = cash_from_bank 
  305. end 
  306.  
  307. function store_crib_category_populate( category_id, total, owned, cash ) 
  308. 	--FIREWALLS were originally in category 2 so we need to move that money into targets 
  309. 	if(category_id == 2) then 
  310. 		Cache_graph_data[1].total_items = Cache_graph_data[1].total_items + total 
  311. 		Cache_graph_data[1].owned_items = Cache_graph_data[1].owned_items + owned 
  312. 		Cache_graph_data[1].cache_earned = Cache_graph_data[1].cache_earned + cash 
  313. 	--FIREWALLS were originally in category 2 so anything after needs to be pushed one position down 
  314. 	elseif( category_id > 2 ) then 
  315. 		local curr_section = Cache_graph_data[ category_id - 1 ] 
  316. 	 
  317. 		curr_section.total_items = total 
  318. 		curr_section.owned_items = owned 
  319. 		curr_section.cache_earned = cash 
  320. 	else 
  321. 		local curr_section = Cache_graph_data[ category_id ] 
  322. 	 
  323. 		curr_section.total_items = total 
  324. 		curr_section.owned_items = owned 
  325. 		curr_section.cache_earned = cash 
  326. 	end 
  327. end 
  328.  
  329. ------------------------------------------------------------------------------- 
  330. -- Process input 
  331. ------------------------------------------------------------------------------- 
  332. function store_crib_input(event) 
  333. 	if event == "back" or event == "select" or event == "map" then	 
  334. 	 
  335. 		-- Input is delayed, return early 
  336. 		if Store_crib_cash_input_is_blocked == true then 
  337. 			return 
  338. 		end 
  339. 		 
  340. 		-- Skip transfer animation if we're transferring 
  341. 		if Crib_cash_screen_state == CRIB_CASH_SCREEN_STATE_TRANSFERING then	 
  342. 				 
  343. 			-- Block input so we don't skip through too quickly 
  344. 			store_crib_cash_input_block_delay() 
  345. 			 
  346. 			-- Set up end events and skip ahead 
  347. 			local transfer_anim_h = vint_object_find("transfer_anim")			 
  348. 			local transfer_event_twn_h = vint_object_find("transfer_event_twn", transfer_anim_h) 
  349. 			 
  350. 			vint_set_property(transfer_event_twn_h, "end_event", "store_crib_cash_pulse_hint") 
  351. 			 
  352. 			lua_play_anim(transfer_anim_h, -6)	 
  353. 			 
  354. 			-- Stop cache transfer audio since we're stopping early 
  355. 			ui_audio_post_event("ui_cache_transfer_stop") 
  356. 			 
  357. 			-- We're done transferring 
  358. 			Crib_cash_screen_state = CRIB_CASH_SCREEN_STATE_POST_TRANSFER 
  359. 			 
  360. 			return 
  361. 		end 
  362. 	 
  363. 		if Crib_cash_screen_state == CRIB_CASH_SCREEN_STATE_POST_TRANSFER then 
  364. 			Input_tracker:subscribe(false) 
  365. 			if Crib_cash_mouse_input_tracker ~= nil then 
  366. 				Crib_cash_mouse_input_tracker:subscribe(false) 
  367. 			end 
  368. 			store_crib_cash_exit() 
  369. 		end 
  370. 	end 
  371. end 
  372.  
  373.  
  374. function store_crib_cash_exit() 
  375. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  376. 	cell_transition_screen(CELL_STATE_PORTRAIT,  CELL_SCREEN_MAIN, CELL_SCREEN_CASH, store_crib_cash_exit_final) 
  377. end 
  378.  
  379.  
  380. function store_crib_cash_nav_map() 
  381. 	ui_audio_post_event("UI_Hub_Menu_Back") 
  382. 	cell_transition_screen(CELL_STATE_OUT,  CELL_SCREEN_NONE, CELL_SCREEN_CASH, store_crib_cash_exit_to_game) 
  383. end 
  384.  
  385.  
  386. function store_crib_cash_exit_final() 
  387. 	pop_screen() 
  388. end 
  389.  
  390.  
  391. function store_crib_cash_exit_to_game() 
  392. 	pop_screen() 
  393. 	pop_screen() 
  394. 	pop_screen() 
  395. end 
  396.  
  397.  
  398. function store_crib_cash_pulse_hint() 
  399. 	Hint_bar:pulse(1) 
  400. end 
  401.  
  402.  
  403. ------------------------------------------------------------------------------- 
  404. -- Cash transfer action... 
  405. ------------------------------------------------------------------------------- 
  406. function store_crib_cash_transfer() 
  407. 	Crib_cash_screen_state = CRIB_CASH_SCREEN_STATE_TRANSFERING 
  408. 	 
  409. 	--init stuff 
  410. 	local start_cash = 0 									-- $ amount to start cash from... 
  411. 	local cash_end = Crib_cash_data.cash_from_bank 	-- $ amount to end cash on... 
  412. 	local cash_this_frame = -1								-- How much cash gets displayed in the current frame...	 
  413. 	local bank_cash_this_frame	= -1						--	 
  414. 	local pct_this_frame	 = -1								-- How much cash gets displayed in the current frame...	 
  415. 	local is_complete = false								-- Is the screen complete? 
  416.  
  417. 	--local amt_min = 100 
  418. 	--local amt_max = 20000 
  419.  
  420. 	local time_max = 3450 
  421. 	local init_time = floor(vint_get_time_index() * 1000) 
  422. 	local cur_time = init_time 
  423. 	local time_to_count = time_max 
  424.  
  425. 	local bank_val_txt_h 							= vint_object_find("bank_val_txt") 
  426. 	local player_cash_val_txt_h 					= vint_object_find("player_cash_val_txt") 
  427. 	 
  428. 	if cash_end > 0 then 
  429. 		 
  430. 		while is_complete == false do 
  431. 		 
  432. 			local cur_time = floor(vint_get_time_index() * 1000) - init_time 
  433. 							 
  434. 			--set my values 
  435. 			pct_this_frame	= (cur_time / time_to_count) 
  436. 			cash_this_frame = cash_end * pct_this_frame 
  437. 			bank_cash_this_frame = cash_end - cash_this_frame 
  438. 			 
  439. 			if cur_time >= time_to_count or Crib_cash_screen_state == CRIB_CASH_SCREEN_STATE_POST_TRANSFER then 
  440. 			 
  441. 				--force the values to end 
  442. 				vint_set_property(player_cash_val_txt_h, "text_tag", "{GAME_CASH}" .. format_cash(cash_end + Crib_cash_data.player_cash )) 
  443. 				vint_set_property(bank_val_txt_h, "text_tag", "{GAME_CASH}" .. "0") 
  444. 				 
  445. 				--End Loop 
  446. 				is_complete = true 
  447. 			else				 
  448. 				vint_set_property(player_cash_val_txt_h, "text_tag", "{GAME_CASH}" .. format_cash(cash_this_frame + Crib_cash_data.player_cash)) 
  449. 				vint_set_property(bank_val_txt_h, "text_tag", "{GAME_CASH}" .. format_cash(bank_cash_this_frame)) 
  450. 			end 
  451. 			 
  452. 			thread_yield()		 
  453. 			 
  454. 		end		 
  455. 	end 
  456. 	 
  457. 	Crib_cash_screen_state = CRIB_CASH_SCREEN_STATE_POST_TRANSFER 
  458. end 
  459.  
  460.  
  461. --RAD_TO_DEG = 57.29199821758228 
  462.  
  463.  
  464. -- Divide pie chart into the correct sections 
  465. -- 
  466. function store_crib_cash_set_graph_values() 
  467. 	local num_items = #Cache_graph_data 
  468. 	local start_angle = 0 
  469. 	local total_cache_earned = Cache_graph_data.total_cache_earned		 
  470. 	 
  471. 	-- Make space for a section if no cache is earned 
  472. 	-- We still want to show it on the graph to let the user know there are more areas to gain income from 
  473. 	local num_zero_sections = 0 
  474. 	local MIN_VALUE = 0.4 
  475. 	 
  476. 	-- How many sections are zero? 
  477. 	for i = 0, num_items do	 
  478. 		local cache_earned = Cache_graph_data[i].cache_earned  
  479. 				 
  480. 		if cache_earned == 0 then 
  481. 			num_zero_sections = num_zero_sections + 1 
  482. 		end 
  483. 	end 
  484. 	 
  485. 	local zero_section_offset = 0 
  486. 	 
  487. 	--Remaining circle of 2pi not taken up by default degree size and spacers 
  488. 	local remaining_pi = STORE_CRIB_CIRCLE_MAX - (MIN_VALUE *(num_items + 1)) - (STORE_CRIB_CASH_GRAPH_SPACER *(num_items + 1)) 
  489. 	 
  490. 	if num_zero_sections < num_items then 
  491. 		zero_section_offset = (num_zero_sections * MIN_VALUE) / (num_items - num_zero_sections) 
  492. 	end 
  493. 	 
  494. 	--Set text, text position, and end angle for each section 
  495. 	for i = 0, num_items do 
  496. 		local curr_section = Cache_graph_data[i]	 
  497. 		local cache_earned = curr_section.cache_earned  
  498. 		local end_angle = 0 
  499. 		 
  500. 		if cache_earned == 0 then 
  501. 			end_angle = start_angle + MIN_VALUE 
  502. 		else 
  503. 			end_angle = start_angle + MIN_VALUE + ((cache_earned/ total_cache_earned) * remaining_pi) 
  504. 		end 
  505. 				 
  506. 		local circle_h = vint_object_find(curr_section.circle) 
  507. 		 
  508. 		local twn_h = vint_object_find(curr_section.twn) 
  509. 		vint_set_property(circle_h, "start_angle", start_angle) 
  510. 		vint_set_property(twn_h, "start_value", start_angle)		 
  511. 		vint_set_property(twn_h, "end_value", end_angle) 
  512. 		 
  513. 		local new_rotation = ((end_angle - start_angle) * 0.5) + start_angle 
  514. 		 
  515. 		vint_set_property(vint_object_find(curr_section.grp), "rotation", new_rotation) 
  516. 		vint_set_property(vint_object_find(curr_section.grp), "alpha", 0) 
  517. 		 
  518. 		local val_txt_h = vint_object_find(curr_section.val_txt) 
  519. 		local title_txt_h = vint_object_find(curr_section.title_txt) 
  520. 		local rotation_grp_h = vint_object_find(curr_section.rotation_grp) 
  521. 		 
  522. 		vint_set_property(val_txt_h, "text_tag", "{GAME_CASH}" ..format_cash(curr_section.cache_earned)) 
  523. 		 
  524. 		-- Using insert values to create a string with the following format: 
  525. 		-- "SECTION TITLE X/Y" 
  526. 		local insert_values = { [0] = curr_section.label, [1] = curr_section.owned_items, [2] = curr_section.total_items }		 
  527. 		local body = vint_insert_values_in_string("HUB_CACHE_SECTION_XY", insert_values)	 
  528. 		vint_set_property(title_txt_h, "text_tag", body) 
  529. 		 
  530. 		vint_set_property(val_txt_h, "tint", curr_section.tint.R, curr_section.tint.G, curr_section.tint.B) 
  531. 		 
  532. 		vint_set_property(rotation_grp_h, "rotation", new_rotation * -1)		 
  533. 		 
  534. 		--If rotation is past 180 flip the alignment 
  535. 		if new_rotation >= 3.14 then 
  536. 			vint_set_property(val_txt_h, "auto_offset", "ne") 
  537. 			vint_set_property(title_txt_h, "auto_offset", "ne")			 
  538. 		end 
  539. 				 
  540. 		--Start the next section at the end of the previous section	 
  541. 		start_angle = end_angle + STORE_CRIB_CASH_GRAPH_SPACER 
  542. 	end 
  543. end 
  544.  
  545.  
  546. ------------------------------------------------------------------------------- 
  547. -- Function store_crib_cash_input_block_delay() 
  548. -- 
  549. -- Delay input for 0.75s so user doesn't skip through the screen too quickly 
  550. -- 
  551. ------------------------------------------------------------------------------- 
  552. function store_crib_cash_input_block_delay() 
  553. 	Store_crib_cash_input_is_blocked = true 
  554. 	 
  555. 	if Store_crib_cash_input_delay_thread ~= -1 then 
  556. 		thread_kill(Store_crib_cash_input_delay_thread) 
  557. 	end 
  558. 	 
  559. 	if Store_crib_cash_input_delay_thread == -1 then 
  560. 		Store_crib_cash_input_delay_thread = thread_new("store_crib_cash_input_block_thread") 
  561. 	end 
  562. end 
  563.  
  564.  
  565. function store_crib_cash_input_block_thread() 
  566. 	delay(.75) 
  567. 	Store_crib_cash_input_is_blocked = false 
  568. 	Store_crib_cash_input_delay_thread = -1 
  569. end 
  570.  
  571.  
  572. -- ===================================== 
  573. --       Mouse Specific Functions 
  574. -- ===================================== 
  575. function store_crib_cash_mouse_click(event, target_handle) 
  576. 	-- Check if the user clicked anywhere on the screen 
  577. 	if target_handle == Bg_image.handle then 
  578. 		store_crib_input("select") 
  579. 		return 
  580. 	end 
  581. 	 
  582. 	-- Check if the user clicked on the hint bar button 
  583. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  584. 	if hint_index ~= 0 then 
  585. 		store_crib_input("select") 
  586. 		return 
  587. 	end 
  588. end 
  589.  
  590.  
  591. function store_crib_cash_mouse_move(event, target_handle) 
  592. 	-- Reset all highlights 
  593. 	Hint_bar:set_highlight(0) 
  594. 	 
  595. 	-- Check if the mouse is over the hint bar buttons 
  596. 	local hint_index = Hint_bar:get_hint_index(target_handle) 
  597. 	if hint_index ~= 0 then 
  598. 		Hint_bar:set_highlight(hint_index) 
  599. 		return 
  600. 	end 
  601. end