sr2lua/cellphone.lua

  1.  
  2. Cellphone_audio = { 
  3. 	[0] =					audio_get_audio_id("SYS_CELL_0"), 
  4. 	[1] = 				audio_get_audio_id("SYS_CELL_1"), 
  5. 	[2] = 				audio_get_audio_id("SYS_CELL_2"), 
  6. 	[3] = 				audio_get_audio_id("SYS_CELL_3"), 
  7. 	[4] =					audio_get_audio_id("SYS_CELL_4"), 
  8. 	[5] = 				audio_get_audio_id("SYS_CELL_5"), 
  9. 	[6] = 				audio_get_audio_id("SYS_CELL_6"), 
  10. 	[7] = 				audio_get_audio_id("SYS_CELL_7"), 
  11. 	[8] = 				audio_get_audio_id("SYS_CELL_8"), 
  12. 	[9] =					audio_get_audio_id("SYS_CELL_9"), 
  13. 	["pound"] =			audio_get_audio_id("SYS_CELL_POUND"), 
  14. 	["star"]  = 		audio_get_audio_id("SYS_CELL_STAR"), 
  15. 	["bootup"]  =	 	audio_get_audio_id("SYS_CELL_BOOTUP"), 
  16. 	["cheat"] = 		audio_get_audio_id("SYS_CELL_MENU_CHEAT"), 
  17. 	["data_entry"] = 	audio_get_audio_id("SYS_CELL_SELECT"), 
  18. 	["nav"] = 			audio_get_audio_id("SYS_CELL_UD"), 
  19. 	["nav_back"] = 	audio_get_audio_id("SYS_CELL_BACK"), 
  20. } 
  21.  
  22.  
  23. CELLPHONE_SUBSCRIPTION_DEPTH = 1000 
  24.  
  25. CELLPHONE_ITEM_TYPE_MAIN = 0 
  26.  
  27. Cellphone = { 
  28. 	handles = {} 
  29. } 
  30.  
  31. Cellphone_phonebook_thread = -1 
  32. Cellphone_nav_blocked = 0 
  33. Cellphone_phonebook_anim_clones = {} 
  34. Cellphone_phonebook_anim_clones.anim_count = 0 
  35. Cellphone_tween_h = 0 
  36. Cellphone_intro_sound_thread = -1 
  37. Cellphone_intro_sound_instance = -1 
  38.  
  39. function cellphone_end_in() 
  40. 	vint_object_destroy(Cellphone_tween_h) 
  41. 	vint_set_property(Menu_option_labels_inactive.frame, "visible", false) 
  42. end 
  43.  
  44. function cellphone_init() 
  45. 	peg_load("ui_cellphone") 
  46. 	 
  47. 	 
  48. 	Cellphone_nav_blocked = 1	 
  49. 	Cellphone.cur_idx = 0 
  50. 	Cellphone.subheader_active = false 
  51. 	Cellphone.initialized = false 
  52. 	 
  53. 	Cellphone.loaded_peg = -1 		--Flag for loading pegs. 
  54. 	Cellphone.number_called = ""	--Current number in use or last used, could be a name or formatted number 
  55. 	Cellphone.cheat_selected_idx = 0 	--Last cheat that was selected. 
  56. 	Cellphone.cheat_selected_desc = 0 	--Last cheat that was selected. 
  57. 	 
  58. 	--Find Objects 
  59. 	Cellphone_menu_main.handles.grp = vint_object_find("main_grp") 
  60. 	Cellphone_menu_main.handles.main_item = vint_object_find("main_item", Cellphone_menu_main.handles.grp) 
  61. 	Cellphone.handles.book_grp = vint_object_find("book_grp") 
  62. 	Cellphone.handles.sub_header = vint_object_find("sub_header") 
  63. 	Cellphone.handles.sub_header_text = vint_object_find("sub_head_text", Cellphone.handles.sub_header) 
  64.  
  65. 	--Dial Objects 
  66. 	Cellphone_menu_dial.handles.grp = vint_object_find("dial_grp") 
  67. 	Cellphone_menu_dial.handles.dial_number = vint_object_find("dial_number_text", Cellphone_menu_dial.handles.grp) 
  68. 	vint_set_property(Cellphone_menu_dial.handles.grp, "visible", false) 
  69. 	 
  70. 	--Call Objects 
  71. 	Cellphone_menu_call.handles.grp = vint_object_find("call_grp") 
  72. 	Cellphone.handles.calling_grp = vint_object_find("calling_grp", Cellphone_menu_call.handles.grp ) 
  73. 	Cellphone.handles.speaking_grp = vint_object_find("speaking_grp", Cellphone_menu_call.handles.grp ) 
  74. 	Cellphone.handles.call_dots = vint_object_find("dots", Cellphone_menu_call.handles.grp ) 
  75. 	Cellphone.handles.call_number_1 = vint_object_find("call_number_text", Cellphone_menu_call.handles.grp ) 
  76. 	Cellphone.handles.call_number_2 = vint_object_find("calling_text", Cellphone.handles.speaking_grp ) 
  77. 	Cellphone.handles.call_text = vint_object_find("calling_text", Cellphone.handles.calling_grp ) 
  78. 	 
  79. 	--Cheat Objects 
  80. 	Cellphone_menu_cheat_activate.handles.grp = vint_object_find("cheat_activated_grp") 
  81. 	Cellphone_menu_cheat_added.handles.grp = vint_object_find("cheat_added_grp") 
  82. 	 
  83. 	--Cheat Added Objects 
  84. 	Cellphone.handles.cheat_added_title = vint_object_find("cheat_added_title", Cellphone_menu_cheat_added.handles.grp) 
  85. 	Cellphone.handles.cheat_added_desc = vint_object_find("cheat_description_text", Cellphone_menu_cheat_added.handles.grp) 
  86. 	 
  87. 	--Cheat activated objects 
  88. 	Cellphone.handles.cheat_activated_state = vint_object_find("activated_text") 
  89. 	Cellphone.handles.cheat_activated_desc = vint_object_find("cheat_desc_text") 
  90. 	Cellphone.handles.cheat_activated_title = vint_object_find("cheat_title_text") 
  91. 	 
  92. 	--Animations 
  93. 	--Background Animation Program 
  94. 	cellphone_bg_anim_init() 
  95. 		 
  96. 	--Bootup anims 
  97. 	Cellphone.handles.intro_anim = vint_object_find("intro_anim") 
  98. 	Cellphone.handles.main_menu_intro_anim = vint_object_find("main_menu_intro_anim") 
  99. 	Cellphone.handles.main_menu_item_twn = vint_object_find("main_item_alpha_twn_1", Cellphone.handles.main_menu_intro_anim ) 
  100. 	Cellphone.handles.main_menu_pulse_anim = vint_object_find("main_item_pulse_anim_1") 
  101. 	 
  102. 	vint_set_property(Cellphone.handles.intro_anim, "is_paused", true) 
  103. 	vint_set_property(Cellphone.handles.main_menu_intro_anim, "is_paused", true)  
  104. 	vint_set_property(Cellphone.handles.main_menu_pulse_anim, "is_paused", true)  
  105. 	 
  106. 	--Bootup callback twns 
  107. 	local twn_h = vint_object_find("intro_bg_alpha_twn_2", Cellphone.handles.intro_anim) 
  108. 	vint_set_property(twn_h, "end_event", "cellphone_menu_main_fade_in") 
  109. 	 
  110. 	--Phone book anims 
  111. 	Cellphone.handles.book_slider_anim = vint_object_find("book_slider_anim") 
  112. 	Cellphone.handles.book_slider_tween = vint_object_find("book_slider_anchor_twn", Cellphone.handles.book_slider_anim) 
  113. 	Cellphone.handles.book_text_select_anim = vint_object_find("book_text_select_anim") 
  114. 	Cellphone.handles.book_text_deselect_anim = vint_object_find("book_text_deselect_anim") 
  115. 	Cellphone.handles.book_image_select_anim = vint_object_find("book_image_select_anim") 
  116. 	Cellphone.handles.book_image_deselect_anim = vint_object_find("book_image_deselect_anim") 
  117. 	Cellphone.handles.book_item_pulse_anim = vint_object_find("book_item_pulse_anim") 
  118. 	 
  119. 	--Pause Animations 
  120. 	vint_set_property(Cellphone.handles.book_slider_anim, "is_paused", true) 
  121. 	vint_set_property(Cellphone.handles.book_text_select_anim, "is_paused", true) 
  122. 	vint_set_property(Cellphone.handles.book_text_deselect_anim, "is_paused", true) 
  123. 	vint_set_property(Cellphone.handles.book_image_select_anim, "is_paused", true) 
  124. 	vint_set_property(Cellphone.handles.book_image_deselect_anim, "is_paused", true) 
  125. 	vint_set_property(Cellphone.handles.book_item_pulse_anim, "is_paused", true) 
  126.  
  127. 	--Calling Animations 
  128. 	Cellphone.handles.calling_to_speak_anim = vint_object_find("calling_to_speak_anim") 
  129. 	vint_set_property(Cellphone.handles.calling_to_speak_anim, "is_paused", true) 
  130. 	Cellphone.handles.calling_dot_anim = vint_object_find("calling_dot_anim") 
  131. 	vint_set_property(Cellphone.handles.calling_dot_anim, "is_paused", true) 
  132. 	Cellphone.handles.calling_dot_twn = vint_object_find("dot3_alpha_twn_2") 
  133. 	vint_set_property(Cellphone.handles.calling_dot_twn, "end_event", "cellphone_call_dot_loop") 
  134. 	 
  135. 	--Callback for looping calling  
  136. 	local twn_h = vint_object_find("book_item_text_dnscale_twn_1", Cellphone.handles.book_text_deselect_anim) 
  137. 	vint_set_property(twn_h, "per_frame_event", "cellphone_phonebook_align") 
  138. 	local twn_h = vint_object_find("book_item_text_upscale_twn_1", Cellphone.handles.book_text_select_anim) 
  139. 	vint_set_property(twn_h, "end_event", "cellphone_phonebook_nav_end") 
  140. 	 
  141. 	--Dial animations 
  142. 	Cellphone.handles.dial_selected_anim = vint_object_find("dial_selected") 
  143. 	Cellphone.handles.dial_selected_twn = vint_object_find("dial_btn_2_alpha_twn_1", Cellphone.handles.dial_selected_anim) 
  144. 	 
  145. 	vint_set_property(Cellphone.handles.book_grp, "visible", false) 
  146. 		 
  147. 	Cellphone.player_cash = 0 
  148.  
  149. 	cellphone_clock_set() 
  150. 	 
  151. 	--Initialize all menus 
  152. 	cellphone_menu_initialize() 
  153. 	 
  154. 	local intro_clip_h = vint_object_find("intro_clip") 
  155. 	vint_set_property(intro_clip_h, "visible", true) 
  156. 	 
  157. 	--Play Bootup animation 
  158. 	lua_play_anim(Cellphone.handles.intro_anim, .5) 
  159. 	 
  160. 	--Play Bootup Sound 
  161. 	cell_audio_play_delayed(Cellphone_audio["bootup"], .6) 
  162. 	 
  163. 	--when complete open up Cellphone_menu_main 
  164. 	cellphone_menu_show(Cellphone_menu_main) 
  165. 	cellphone_menu_main_item_nav(0,0) 
  166. 	 
  167. 	--Subscribe to player information for cash data 
  168. 	vint_dataitem_add_subscription("sr2_local_player_status_infrequent", "update", "cellphone_cash_update") 
  169. 	 
  170. 	--Subscribe to input 
  171. 	cellphone_subscribe_input() 
  172. end 
  173.  
  174. function cellphone_subscribe_input() 
  175. 	local c = Cellphone 
  176. 	c.input_subs = {	 
  177. 		vint_subscribe_to_input_event(nil, "nav_up",				"cellphone_input_event", 50), 
  178. 		vint_subscribe_to_input_event(nil, "nav_down",			"cellphone_input_event", 50), 
  179. 		vint_subscribe_to_input_event(nil, "nav_right",			"cellphone_input_event", 50), 
  180. 		vint_subscribe_to_input_event(nil, "nav_left",			"cellphone_input_event", 50), 
  181. 		vint_subscribe_to_input_event(nil, "select",				"cellphone_input_event", 50), 
  182. 		vint_subscribe_to_input_event(nil, "pause",				"cellphone_input_event", 50), 
  183. 		vint_subscribe_to_input_event(nil, "back",				"cellphone_input_event", 100), 
  184. 	} 
  185. end 
  186.  
  187. function cellphone_desubscribe_input() 
  188. 	--	Unsubscribe to input 
  189. 	local c = Cellphone 
  190. 	for idx, val in c.input_subs do 
  191. 		vint_unsubscribe_to_input_event(val) 
  192. 	end 
  193. 	c.input_subs = nil 
  194. end 
  195.  
  196. function cellphone_menu_main_fade_in() 
  197. 	--Plays Main Menu intro animation 
  198. 	lua_play_anim(Cellphone.handles.main_menu_intro_anim) 
  199. end 
  200.  
  201. function cellphone_menu_show(menu) 
  202. 	local c = Cellphone 
  203. 	 
  204. 	--Make sure menu inactive is totally hidden 
  205. 	if c.menu_inactive ~= nil then 
  206. 		vint_set_property(c.menu_inactive.handles.grp, "alpha", 0) 
  207. 	end 
  208. 	 
  209. 	c.menu_inactive = c.menu_active  
  210. 	c.menu_active = menu 
  211. 	Pause_cellphone_btn_tips.b_button.label = "MENU_BACK" 
  212.  
  213. 	if c.menu_active.menu_type == "main" then 
  214. 		--Unload image peg if its loaded 
  215. 		if Cellphone.loaded_peg ~= -1 then 
  216. 			peg_unload(Cellphone.loaded_peg) 
  217. 			Cellphone.loaded_peg = -1 
  218. 		end 
  219. 		 
  220. 		--hide subheader 
  221. 		cellphone_subheader_hide() 
  222. 		 
  223. 		Pause_cellphone_btn_tips.b_button.label = "CONTROL_RESUME" 
  224.  
  225. 		 
  226. 		if c.menu_active.initialized == nil then 
  227. 			local phone_h = vint_object_find("cell_phone") 
  228. 			vint_set_property(phone_h, "visible", true) 
  229. 			 
  230. 			local t1 = Menu_active_anchor_end_x - Menu_inactive.menu_width 
  231. 			local tween_h = menu_create_tween("cell_phone_custom_transition_in", phone_h, "anchor", 0.15) 
  232. 			vint_set_property(tween_h, "start_value", t1, Menu_active_anchor_end_y) 
  233. 			vint_set_property(tween_h, "end_value", Menu_active_anchor_end_x, Menu_active_anchor_end_y) 
  234. 			vint_set_property(tween_h, "end_event", "cellphone_end_in") 
  235. 			 
  236. 			Cellphone_tween_h = tween_h 
  237. 	 
  238. 			c.cur_idx = c.menu_active.cur_idx 
  239. 			c.menu_active.initialized = true 
  240. 	 
  241. 			Menu_active.menu_width = element_get_actual_size(phone_h) 
  242.  
  243. 			vint_set_property(c.menu_active.handles.grp, "visible", true) 
  244. 			return 
  245. 		end 
  246. 		 
  247. 	elseif c.menu_active.menu_type == "homies" or c.menu_active.menu_type == "phonebook"  then 
  248. 		--Show the subheader 
  249. 		cellphone_subheader_show(c.menu_active.header_string) 
  250. 		 
  251. 		--Create menu 
  252. 		cellphone_phonebook_create() 
  253. 	elseif c.menu_active.menu_type == "dial" then 
  254. 		cellphone_dial_show()	 
  255. 	elseif c.menu_active.menu_type == "call" then 
  256. 		cellphone_call_show() 
  257. 	elseif c.menu_active.menu_type == "cheat_activated" then 
  258. 		--Only update the header 
  259. 		cellphone_subheader_hide() 
  260. 	elseif c.menu_active.menu_type == "cheat_added" then 
  261. 		--Only update the header 
  262. 		cellphone_subheader_show(c.menu_active.header_string) 
  263. 	end 
  264. 	 
  265. 	--Reset control index 
  266. 	c.cur_idx = c.menu_active.cur_idx 
  267.  
  268. 	--Menu Transitions 
  269. 	 
  270. 	--Slide out old menu 
  271. 	if c.menu_inactive ~= nil then 
  272. 		vint_set_property(c.menu_inactive.handles.grp, "alpha", 0) 
  273. 		vint_set_property(c.menu_inactive.handles.grp, "visible", false) 
  274. 		if c.menu_inactive.cleanup ~= nil then 
  275. 			c.menu_inactive.cleanup() 
  276. 		end 
  277. 	end 
  278. 	 
  279. 	--Then slide in new menu 
  280. 	vint_set_property(c.menu_active.handles.grp, "visible", true) 
  281. 	local twn_h = cellphone_create_tween("cleanout", c.menu_active.handles.grp, "alpha", .5) 
  282. 	vint_set_property(twn_h, "start_value", 0) 
  283. 	vint_set_property(twn_h, "end_value", 1) 
  284. 	 
  285. 	btn_tips_update() 
  286. end 
  287.  
  288. function cell_phone_exit_tween(callback) 
  289. 	local phone_h = vint_object_find("cell_phone") 
  290. 	vint_set_property(phone_h, "visible", true) 
  291. 			 
  292. 	local t1 = Menu_active.menu_width - Menu_active_anchor_end_x 
  293. 	local tween_h = menu_create_tween("cell_phone_custom_transition_out", phone_h, "anchor", 1.5) 
  294. 	vint_set_property(tween_h, "start_value", t1, Menu_active_anchor_end_y) 
  295. 	vint_set_property(tween_h, "end_value", 0, Menu_active_anchor_end_y) 
  296. 	vint_set_property(tween_h, "end_event", callback) 
  297. 			 
  298. 	Cellphone_tween_h = tween_h 
  299. end 
  300.  
  301. function cellphone_create_tween(name, target_h, target_prop, duration) 
  302. 	local tween_h = vint_object_create(name, "tween", vint_object_find("root_animation")) 
  303. 	 
  304. 	vint_set_property(tween_h, "duration", duration) 
  305. 	vint_set_property(tween_h, "target_handle", target_h) 
  306. 	vint_set_property(tween_h, "target_property", target_prop) 
  307. 	vint_set_property(tween_h, "start_time",	vint_get_time_index()) 
  308. 	vint_set_property(tween_h, "is_paused", false) 
  309. 	vint_set_property(tween_h, "end_event", "cellphone_tween_cleanup") 
  310. 	return tween_h 
  311. end 
  312.  
  313. function cellphone_tween_cleanup(twn_h) 
  314. 	--Destroy tweens for cellphone fade in 
  315. 	vint_object_destroy(twn_h) 
  316. end 
  317.  
  318. --Input event handler 
  319. function cellphone_input_event(target, event, accelleration) 
  320. 	 
  321. 	if get_platform() ~= "PC" then 
  322. 		--Always handle unpausing 
  323. 		if event == "pause" then 
  324. 			pause_menu_exit() 
  325. 			--vint_document_unload(vint_document_find("cellphone")) 
  326. 		end 
  327. 	end 
  328. 	 
  329. 	if event == "back" and Cellphone.initialized == false then 
  330. 		--Only allow the user to go back if the nav isn't blocked before the cell is initialized 
  331. 		cellphone_menu_main_back(0) 
  332. 	end 
  333. 	 
  334. 	local c = Cellphone 
  335. 	local old_idx = -1 
  336. 	 
  337. 	--Check if nav is blocked 
  338. 	if cellphone_nav_is_blocked() == true then 
  339. 		return 
  340. 	end 
  341. 	 
  342. 	if c.cur_idx == nil then 
  343. 		--don't handle any events if there is no index 
  344. 		return 
  345. 	end 
  346. 	if event == "nav_up" then 
  347. 		--Call nav function 
  348. 		if c.menu_active.on_nav_up ~= nil then 
  349. 			c.menu_active.on_nav_up(c.cur_idx) 
  350. 		else 
  351. 			old_idx = c.cur_idx 
  352. 			 
  353. 			if c.cur_idx == 0 then			--	Wrap around if we have to 
  354. 				c.cur_idx = c.menu_active.num_items - 1 
  355. 			else 
  356. 				c.cur_idx = c.cur_idx - 1	--	Otherwise move it up 
  357. 			end 
  358. 			 
  359. 			--Store index to menu 
  360. 			c.menu_active.cur_idx = c.cur_idx 	 
  361. 			if c.menu_active.on_nav ~= nil then 
  362. 				c.menu_active.on_nav(c.cur_idx, old_idx) 
  363. 			end 
  364. 		end 
  365. 	elseif event == "nav_down" then 
  366. 		if c.menu_active.on_nav_down ~= nil then 
  367. 			c.menu_active.on_nav_down(c.cur_idx) 
  368. 		else 
  369. 			old_idx = c.cur_idx 
  370.  
  371. 			if c.cur_idx == c.menu_active.num_items - 1 then			--	Wrap around if we have to 
  372. 				c.cur_idx = 0 
  373. 			else 
  374. 				c.cur_idx = c.cur_idx + 1	--	Otherwise move it up 
  375. 			end 
  376. 			 
  377. 			--Store index to menu 
  378. 			c.menu_active.cur_idx = c.cur_idx  
  379. 			 
  380. 			--Call nav function 
  381. 			if c.menu_active.on_nav ~= nil then 
  382. 				c.menu_active.on_nav(c.cur_idx, old_idx) 
  383. 			end 
  384. 		end 
  385. 	elseif event == "nav_right" then 
  386. 		if c.menu_active.on_nav_right ~= nil then 
  387. 			c.menu_active.on_nav_right(c.cur_idx) 
  388. 		end 
  389. 	elseif event == "nav_left" then 
  390. 		if c.menu_active.on_nav_left ~= nil then 
  391. 			c.menu_active.on_nav_left(c.cur_idx) 
  392. 		end 
  393. 	elseif event == "select" then 
  394. 		if c.menu_active[c.cur_idx].on_select ~= nil then 
  395. 			--Use menu items control 
  396. 			c.menu_active[c.cur_idx].on_select(c.cur_idx)	 
  397. 		elseif c.menu_active.on_select ~= nil then 
  398. 			--Use standard menu select 
  399. 			c.menu_active.on_select(c.cur_idx) 
  400. 		end 
  401. 	elseif event == "back" then 
  402. 		if c.menu_active.on_back ~= nil then 
  403. 			--Use standard menu select 
  404. 			c.menu_active.on_back(c.cur_idx) 
  405. 		end 
  406. 	end 
  407. end 
  408.  
  409. function cellphone_menu_initialize() 
  410.  
  411. 	--Main Menu Init 
  412. 	local menu_item, menu_item_grp_h, h 
  413. 	--Get item width and height 
  414. 	h = vint_object_find("main_border_line", Cellphone_menu_main.handles.main_item) 
  415.  
  416. 	--debug_print("vint", "main_border_line \n")	 
  417. 	 
  418. 	local item_width, item_height = element_get_actual_size(h) 
  419. 	local item_x, item_y = vint_get_property(Cellphone_menu_main.handles.main_item, "anchor") 
  420. 	local item_spacing = 3 
  421. 	 
  422. 	for i = 0, Cellphone_menu_main.num_items - 1 do	 
  423. 		menu_item = Cellphone_menu_main[i] 
  424. 		 
  425. 		if i == 0 then 
  426. 			menu_item.grp_h = Cellphone_menu_main.handles.main_item 
  427. 		else 
  428. 			--clone item 
  429. 			menu_item.grp_h = vint_object_clone(Cellphone_menu_main.handles.main_item) 
  430. 			 
  431. 			--Clone intro tweens and target and time them 
  432. 			local twn_h = vint_object_clone(Cellphone.handles.main_menu_item_twn, Cellphone.handles.main_menu_intro_anim) 
  433. 			vint_set_property(twn_h, "target_handle", menu_item.grp_h) 
  434. 			local start_offset = 0.166665 
  435. 			local duration_offset = vint_get_property(twn_h, "duration") / 2 
  436. 			local start = start_offset + i * duration_offset  
  437. 			vint_set_property(twn_h, "start_time", start)  
  438. 			 
  439. 			if i == Cellphone_menu_main.num_items - 1 then 
  440. 				--Set Callback on last tween to unblock input 
  441. 				vint_set_property(twn_h, "end_event", "cellphone_menu_intro_complete") 
  442. 			end 
  443. 		end 
  444. 		 
  445. 		--Reposition 
  446. 		vint_set_property(menu_item.grp_h, "anchor", item_x, item_y + i * (item_height + item_spacing)) 
  447. 		 
  448. 		--Change Elements 
  449. 		h = vint_object_find("main_sel_text", menu_item.grp_h) 
  450. 		vint_set_property(h, "text_tag", menu_item.label) 
  451. 		 
  452. 		--BMP 
  453. 		h = vint_object_find("main_sel_icon", menu_item.grp_h) 
  454. 		vint_set_property(h, "image", menu_item.bmp) 
  455. 		 
  456. 		--bmp_offset_x, bmp_offset_y 
  457. 		vint_set_property(h, "offset", menu_item.bmp_offset_x, menu_item.bmp_offset_y) 
  458. 		 
  459. 		--Hide elements 
  460. 		vint_set_property(menu_item.grp_h, "alpha", 0) 
  461. 	end 
  462. 	 
  463. 	--Pause anim again because clones do not respond to the animation state 
  464. 	vint_set_property(Cellphone.handles.main_menu_intro_anim, "is_paused", true) 
  465. 		 
  466. 	--Dial Interface 
  467. 	Cellphone_menu_dial[0] 	= 	{h = vint_object_find("dial_btn_call"), 	btn_type = "call" } 
  468. 	Cellphone_menu_dial[1] 	= 	{h = vint_object_find("dial_btn_call"), 	btn_type = "call" } 
  469. 	Cellphone_menu_dial[2] 	= 	{h = vint_object_find("dial_btn_clr"), 	btn_type = "clr" } 
  470. 	Cellphone_menu_dial[3] 	= 	{h = vint_object_find("dial_btn_1"), 		btn_type = "num", id=1 } 
  471. 	Cellphone_menu_dial[4] 	= 	{h = vint_object_find("dial_btn_2"), 		btn_type = "num", id=2 } 
  472. 	Cellphone_menu_dial[5] 	= 	{h = vint_object_find("dial_btn_3"), 		btn_type = "num", id=3 } 
  473. 	Cellphone_menu_dial[6] 	= 	{h = vint_object_find("dial_btn_4"), 		btn_type = "num", id=4 } 
  474. 	Cellphone_menu_dial[7] 	= 	{h = vint_object_find("dial_btn_5"), 		btn_type = "num", id=5 } 
  475. 	Cellphone_menu_dial[8] 	= 	{h = vint_object_find("dial_btn_6"), 		btn_type = "num", id=6 } 
  476. 	Cellphone_menu_dial[9] 	= 	{h = vint_object_find("dial_btn_7"), 		btn_type = "num", id=7 } 
  477. 	Cellphone_menu_dial[10] = 	{h = vint_object_find("dial_btn_8"), 		btn_type = "num", id=8 } 
  478. 	Cellphone_menu_dial[11] = 	{h = vint_object_find("dial_btn_9"), 		btn_type = "num", id=9 } 
  479. 	Cellphone_menu_dial[12] = 	{h = vint_object_find("dial_btn_star"), 	btn_type = "star", id="*"} 
  480. 	Cellphone_menu_dial[13] = 	{h = vint_object_find("dial_btn_oper"), 	btn_type = "num", id=0 } 
  481. 	Cellphone_menu_dial[14] = 	{h = vint_object_find("dial_btn_pound"), 	btn_type = "pound", id="#"} 
  482. 	Cellphone_menu_dial.num_items = 15 
  483. 	Cellphone_menu_dial.num_cols = 3 
  484. 	Cellphone_menu_dial.num_rows = 5 
  485. end 
  486.  
  487. function cellphone_menu_main_item_nav(idx, old_idx) 
  488.  
  489. 	local menu_active = Cellphone.menu_active 
  490. 	local grp_h, h 
  491. 	 
  492. 	if old_idx ~= idx then 
  493. 		--unhighlight old 
  494. 		grp_h = menu_active[old_idx].grp_h 
  495. 			 
  496. 		--change text highlight 
  497. 		h = vint_object_find("main_sel_text", grp_h) 
  498. 		vint_set_property(h, "alpha", .5) 
  499. 			 
  500. 		--bmp 
  501. 		h = vint_object_find("main_sel_icon", grp_h) 
  502. 		vint_set_property(h, "tint", .64, .64, .64) 
  503. 		 
  504. 		--border 
  505. 		h = vint_object_find("main_border", grp_h) 
  506. 		vint_set_property(h, "alpha", .2) 
  507. 	end	 
  508. 	 
  509. 	--highlight new 
  510. 	grp_h = menu_active[idx].grp_h 
  511. 		 
  512. 	--change text highlight 
  513. 	h = vint_object_find("main_sel_text", grp_h) 
  514. 	vint_set_property(h, "alpha", 1) 
  515. 		 
  516. 	--bmp 
  517. 	h = vint_object_find("main_sel_icon", grp_h) 
  518. 	vint_set_property(h, "tint", 1, 1, 1) 
  519. 	 
  520. 	--border 
  521. 	h = vint_object_find("main_border", grp_h) 
  522. 	vint_set_property(h, "alpha", .8) 
  523. 	 
  524. 	vint_set_property(Cellphone.handles.main_menu_pulse_anim, "target_handle", grp_h) 
  525. 	lua_play_anim(Cellphone.handles.main_menu_pulse_anim, 0) 
  526. 	audio_play(Cellphone_audio["nav"]) 
  527. end 
  528.  
  529. --Event to load the submenu based on the idx of the menu item 
  530. function cellphone_menu_main_item_select(idx) 
  531. 	--Always set current index of submenu to zero here 
  532. 	Cellphone.menu_active[idx].sub_menu.cur_idx = 0	 
  533. 	cellphone_menu_show(Cellphone.menu_active[idx].sub_menu) 
  534. 	 
  535. 	--Play Data Entry sound 
  536. 	audio_play(Cellphone_audio["data_entry"])	 
  537. end 
  538.  
  539. function cellphone_menu_main_back(idx) 
  540. 	--Exit the pause menu 
  541. 	vint_document_unload(vint_document_find("cellphone")) 
  542. 	pause_menu_exit() 
  543. end 
  544.  
  545. function cellphone_menu_intro_complete() 
  546. 	Cellphone.initialized = true 
  547. 	cellphone_nav_block(false) 
  548. end 
  549.  
  550. --Numbers to cull out  
  551. CELLPHONE_MAX_PHONEBOOK_NUMBERS = 10 
  552.  
  553.  
  554. ------------------------------------- 
  555. -- Phone Book 
  556. ------------------------------------- 
  557. function cellphone_phonebook_create() 
  558. 	if cellphone_nav_is_blocked() == true then 
  559. 		cellphone_nav_block(false) 
  560. 	end 
  561. 	 
  562. 	local c = Cellphone 
  563. 	local menu_data = Cellphone.menu_active 
  564.  
  565. 	--Create a clone of the menu 
  566. 	menu_data.handles.grp = vint_object_clone(Cellphone.handles.book_grp) 
  567. 	menu_data.handles.scrollbar = vint_object_find("scrollbar_bmp", menu_data.handles.grp) 
  568. 	 
  569. 	--Initialize menu if the menu is suspposed to be dynamic 
  570. 	if	menu_data.dynamic_menu == true then 
  571. 		menu_data.num_items = 0 
  572. 		if menu_data.book_type == 3 then 
  573. 			--Populating Cheats 
  574. 			vint_dataresponder_request("pause_menu_populate", "cellphone_phonebook_populate_cheats", 0, 16, menu_data.book_type, Cellphone.number_called)  
  575. 		elseif menu_data.book_type == 4 then 
  576. 			debug_print("vint", "populate_garage\n") 
  577. 			--Populate Garage List 
  578. 			vint_dataresponder_request("pause_menu_populate", "cellphone_phonebook_populate_garage", 0, 16, 4)  
  579. 		else 
  580. 			--Populate Starndard list 
  581. 			vint_dataresponder_request("pause_menu_populate",	"cellphone_phonebook_populate", 0, 16, menu_data.book_type) 
  582. 		end 
  583. 		 
  584. 		--Always reset to index of zero if the menu is dynamically generated 
  585. 		menu_data.cur_idx = 0 
  586. 		local slider_h = vint_object_find("book_slider", menu_data.handles.grp) 
  587. 		vint_set_property(slider_h, "anchor", 0, 0) 
  588. 	end 
  589. 	debug_print("vint", "menu_data.num_items: " .. menu_data.num_items .. "\n") 
  590. 	 
  591. 	--Load phone images 
  592. 	if menu_data.image_peg ~= -1 then 
  593. 		--Unload last image in case it was loaded 
  594. 		if Cellphone.loaded_peg ~= -1 then 
  595. 			peg_unload(Cellphone.loaded_peg) 
  596. 			Cellphone.loaded_peg = -1 
  597. 		end 
  598. 		 
  599. 		--Load new peg 
  600. 		peg_load(menu_data.image_peg) 
  601. 		Cellphone.loaded_peg = menu_data.image_peg 
  602. 	end 
  603. 	 
  604. 	local menu_item_h = vint_object_find("book_item", menu_data.handles.grp) 
  605. 	vint_set_property(menu_item_h, "visible", false) 
  606. 	local h, x, y, width, height 
  607. 	local menu_item, old_h, text_h, bmp_h, text_x, text_y  
  608. 	local item_spacing = 0 
  609. 	 
  610. 	local contact_text_tag = "" 
  611. 	 
  612. 	--Now create each item from the menu data 
  613. 	for i = 0, menu_data.num_items - 1 do 
  614. 		if i > CELLPHONE_MAX_PHONEBOOK_NUMBERS then 
  615. 			--Too many for the screen 
  616. 			menu_data[i].grp_h = -1 
  617. 		else 
  618. 			cellphone_phonebook_add_to_list(i) 
  619. 		end 
  620. 	end 
  621. 	 
  622. 	--highlight cur idx and make the cur index selectable 
  623. 	local menu_item = menu_data[menu_data.cur_idx] 
  624. 	local text_h = vint_object_find("book_item_text", menu_item.grp_h)	 
  625. 	local bmp_h = vint_object_find("book_image", menu_item.grp_h) 
  626. 	width, height = vint_get_property(bmp_h, "source_se") 
  627. 	vint_set_property(text_h, "tint", .529, .725, .815) 
  628. 	 
  629. 	local text_string = vint_get_property(text_h, "text_tag") 
  630. 	--debug_print("vint", "text0: " .. var_to_string(text_string)  .. "\n") 
  631. 	if text_string ~= nil then 
  632. 		cellphone_phonebook_resize_static_text(text_h, 1.2, true) 
  633. 	end 
  634.  
  635. 	--vint_set_property(text_h, "scale", 1.2,1.2) 
  636. 	if menu_data.image_peg ~= -1 then 
  637. 		height = 98 
  638. 		vint_set_property(bmp_h, "source_se", width, height) 
  639. 		vint_set_property(bmp_h, "alpha", 1) 
  640. 		vint_set_property(text_h, "anchor", 0, height) 
  641. 	end 
  642.  
  643. 	--Align all items 
  644. 	cellphone_phonebook_align() 
  645. 	cellphone_phonebook_update_layout() 
  646. end 
  647.  
  648.  
  649.  
  650. function cellphone_phonebook_nav(idx, old_idx) 
  651. 	local menu_data = Cellphone.menu_active 
  652. 	local grp_h, h 
  653.  
  654. 	if menu_data.num_items <= 1 then 
  655. 		--No Items or one item in list in list reset the index 
  656. 		menu_data.cur_idx = old_idx 
  657. 		Cellphone.cur_idx = old_idx 
  658. 		return 
  659. 	end 
  660. 	 
  661. 	local nav_distance = abs(idx - old_idx) 
  662. 	if nav_distance > 1 then 
  663. 		--reset the index 
  664. 		menu_data.cur_idx = old_idx 
  665. 		Cellphone.cur_idx = old_idx 
  666. 		return 
  667. 	end 
  668. 	 
  669. 	--Block input 
  670. 	cellphone_nav_block(true) 
  671. 	 
  672. 	local h, x, y, width, height 
  673. 	local menu_item, old_h, text_h 
  674. 	local item_spacing = 0 
  675.  
  676. 	local temp 
  677.  
  678. 	--Highlight New 
  679. 	menu_item = menu_data[idx] 
  680. 		 
  681. 	--Retarget and Play selected animation 
  682. 	vint_set_property(Cellphone.handles.book_text_select_anim, "target_handle", menu_item.grp_h) 
  683. 	text_h = vint_object_find("book_item_text", menu_item.grp_h) 
  684. 		 
  685. 	--resize the tween targets if necessary 
  686. 	local text_string = vint_get_property(text_h, "text_tag") 
  687. 		 
  688. 	if text_string ~= nil then 
  689. 		cellphone_resize_upscale_animation(text_h) 
  690. 	end 
  691.  
  692. 	lua_play_anim(Cellphone.handles.book_text_select_anim, 0) 
  693. 	 
  694. 	--Retarget and Play selected animation on images if available 
  695. 	if menu_data.image_peg ~= -1 then 
  696. 		vint_set_property(Cellphone.handles.book_image_select_anim, "target_handle", menu_item.grp_h) 
  697. 		lua_play_anim(Cellphone.handles.book_image_select_anim, 0) 
  698. 	end 
  699. 	 
  700. 	--Target pulsing anim 
  701. 	vint_set_property(Cellphone.handles.book_item_pulse_anim, "target_handle", menu_item.grp_h) 
  702. 	lua_play_anim(Cellphone.handles.book_item_pulse_anim, 0) 
  703. 	 
  704. 	--Colaps the previous item 
  705. 	if old_idx ~= idx then	 
  706. 	 
  707. 		--Colaps old 
  708. 		menu_item = menu_data[old_idx] 
  709. 		 
  710. 		--Reset alpha stat of text from pulsing animation 
  711. 		local text_h = vint_object_find("book_item_text", menu_item.grp_h) 
  712. 		vint_set_property(text_h, "alpha", 1) 
  713. 		 
  714. 		--Deselect the item (Make it shrink with animation) 
  715. 		vint_set_property(Cellphone.handles.book_text_deselect_anim, "target_handle", menu_item.grp_h) 
  716.  
  717. 		--resize the tween targets if necessary 
  718. 		local text_string = vint_get_property(text_h, "text_tag") 
  719. 		 
  720. 		if text_string ~= nil then 
  721. 			cellphone_resize_dnscale_animation(text_h) 
  722. 		end 
  723. 	 
  724. 		lua_play_anim(Cellphone.handles.book_text_deselect_anim, 0) 
  725. 		 
  726. 		--If the menu uses images play the deslect animation for images too 
  727. 		if menu_data.image_peg ~= -1 then 
  728. 			vint_set_property(Cellphone.handles.book_image_deselect_anim, "target_handle", menu_item.grp_h) 
  729. 			lua_play_anim(Cellphone.handles.book_image_deselect_anim, 0) 
  730. 		end		 
  731. 	end 
  732. 	 
  733. 	 
  734. 	 
  735. 	 
  736. 	audio_play(Cellphone_audio["nav"]) 
  737. 	 
  738. 	cellphone_phonebook_update_layout() 
  739. end 
  740.  
  741. function cellphone_resize_dnscale_animation(target) 
  742. 	local text_width, text_height 
  743.  
  744. 	--get the normal size, not the big animated size 
  745. 	vint_set_property(target, "scale", 1, 1) 
  746. 	text_width, text_height = element_get_actual_size(target) 
  747. 	 
  748. 	--if bigger than window, rescale the tween targets 
  749. 	if text_width * 1.2 > 258 then 
  750. 		local scale = (258 / text_width) 
  751. 		local twn_h = vint_object_find("book_item_text_dnscale_twn_1", Cellphone.handles.book_text_deselect_anim) 
  752. 		vint_set_property(twn_h, "start_value", scale, scale) 
  753. 	else 
  754. 		local twn_h = vint_object_find("book_item_text_dnscale_twn_1", Cellphone.handles.book_text_deselect_anim) 
  755. 		vint_set_property(twn_h, "start_value", 1.2, 1.2) 
  756. 	end 
  757. 	 
  758. 	if text_width > 258 then 
  759. 		local scale = 258/text_width 
  760. 		local twn_h = vint_object_find("book_item_text_dnscale_twn_1", Cellphone.handles.book_text_deselect_anim) 
  761. 		vint_set_property(twn_h, "end_value", scale, scale) 
  762. 	else 
  763. 		local twn_h = vint_object_find("book_item_text_dnscale_twn_1", Cellphone.handles.book_text_deselect_anim) 
  764. 		vint_set_property(twn_h, "end_value", 1.0, 1.0) 
  765. 	end 
  766. 	 
  767. end 
  768.  
  769. function cellphone_resize_upscale_animation(target) 
  770. 	local text_width, text_height 
  771. 	 
  772. 	--get the normal size, not the big animated size 
  773. 	vint_set_property(target, "scale", 1, 1) 
  774. 	text_width, text_height = element_get_actual_size(target) 
  775. 	 
  776. 	--if bigger than window, rescale the tween targets 
  777. 	if (text_width * 1.2) > 258 then 
  778. 		local scale = 258 / text_width 
  779. 		local twn_h = vint_object_find("book_item_text_upscale_twn_1", Cellphone.handles.book_text_select_anim) 
  780. 		vint_set_property(twn_h, "end_value", scale, scale) 
  781. 	else 
  782. 		local twn_h = vint_object_find("book_item_text_upscale_twn_1", Cellphone.handles.book_text_select_anim) 
  783. 		vint_set_property(twn_h, "end_value", 1.2, 1.2) 
  784. 	end 
  785. 	 
  786. 	if (text_width) > 258 then 
  787. 		local scale = 258 / text_width 
  788. 		local twn_h = vint_object_find("book_item_text_upscale_twn_1", Cellphone.handles.book_text_select_anim) 
  789. 		vint_set_property(twn_h, "start_value", scale, scale) 
  790. 	else 
  791. 		local twn_h = vint_object_find("book_item_text_upscale_twn_1", Cellphone.handles.book_text_select_anim) 
  792. 		vint_set_property(twn_h, "start_value", 1.0, 1.0) 
  793. 	end 
  794. end 
  795.  
  796. function cellphone_phonebook_resize_static_text(target, scale, is_selected) 
  797. 	local text_width, text_height 
  798. 	 
  799. 	--Set Default Size 
  800. 	if scale == nil then 
  801. 		scale = 1.2 
  802. 	end 
  803. 	 
  804. 	--get the normal size, not the big animated size 
  805. 	vint_set_property(target, "scale", 1, 1) 
  806. 	text_width, text_height = element_get_actual_size(target) 
  807.  
  808. 	if is_selected == true then 
  809. 		--check against selected size, and rescale accordingly 
  810. 		if (text_width * 1.2) > 258 then 
  811. 			--if text is bigger than we need to use a smaller scale 
  812. 			scale = ( 258 / text_width ) 
  813. 			vint_set_property(target, "scale", scale, scale) 
  814. 		else 
  815. 			--Otherwise just use the size specified 
  816. 			vint_set_property(target, "scale", scale, scale) 
  817. 		end	 
  818. 	else 
  819. 		--check normal size, and rescale 
  820. 		if (text_width) > 258 then 
  821. 			scale = ( 258 / text_width ) 
  822. 			vint_set_property(target, "scale", scale, scale) 
  823. 		else 
  824. 			vint_set_property(target, "scale", scale, scale) 
  825. 		end 
  826. 	end 
  827. end 
  828.  
  829.  
  830.  
  831. function cellphone_phonebook_update_layout() 
  832. 	local menu_data = Cellphone.menu_active 
  833. 	 
  834. 	if menu_data.num_items == 0 then 
  835. 		--No items so there is nothing to update and there is no scrollbar 
  836. 		vint_set_property(Cellphone.menu_active.handles.scrollbar, "visible", false) 
  837. 		return 
  838. 	end 
  839. 	 
  840. 	--Current Index 
  841. 	local idx = menu_data.cur_idx 
  842. 	local line_height = 0 
  843. 	local text_h = vint_object_find("book_item_text", menu_data[idx].grp_h) 
  844. 	 
  845. 	local text_string = vint_get_property(text_h, "text_tag") 
  846. 	local temp, line_height = element_get_actual_size(text_h) 
  847. 	line_height = line_height 
  848. 	 
  849. 	-- Slide menu 
  850. 	local CELLPHONE_BOOK_TOP_LOCK 
  851. 	local CELLPHONE_BOOK_BOTTOM_LOCK 
  852. 	local DISPLAY_MAX_ITEMS 
  853. 	 
  854. 	--Does the book use images or not? 
  855. 	if menu_data.image_peg == -1 then 
  856. 		--No image defaults 
  857. 		CELLPHONE_BOOK_TOP_LOCK = 4 
  858. 		CELLPHONE_BOOK_BOTTOM_LOCK = 6 
  859. 		DISPLAY_MAX_ITEMS = 10.5 
  860. 	else  
  861. 		--With Image Defaults 
  862. 		CELLPHONE_BOOK_TOP_LOCK = 2 
  863. 		CELLPHONE_BOOK_BOTTOM_LOCK = 5	 
  864. 		DISPLAY_MAX_ITEMS = 7  
  865. 	end 
  866. 	 
  867. 	local bottom_lock = menu_data.num_items - CELLPHONE_BOOK_BOTTOM_LOCK  
  868. 	local bottom_lock_locker = menu_data.num_items - CELLPHONE_BOOK_BOTTOM_LOCK - CELLPHONE_BOOK_TOP_LOCK  
  869. 	 
  870. 	local SCROLLBAR_MAX_HEIGHT = 304 
  871. 	local SCROLLBAR_MIN_HEIGHT = 100 
  872. 	 
  873. 	local max_items = menu_data.num_items - CELLPHONE_BOOK_BOTTOM_LOCK 
  874.  
  875. 	-- Scroll Bar Height 
  876. 	local max_vis = (menu_data.num_items) / DISPLAY_MAX_ITEMS 	--	Get the total items and divide it by the max that can be seen 
  877. 	local height = SCROLLBAR_MAX_HEIGHT / max_vis 					-- The height is the area of the scroll bar divided by the ratio of max items to visible items 
  878. 		 
  879. 	local first_item_to_scroll = idx - CELLPHONE_BOOK_TOP_LOCK	-- Account for the lock at the top 
  880. 	local scrolling_item = first_item_to_scroll 
  881. 	 
  882. 	-- Make sure everything lines up correctly. 
  883. 	if first_item_to_scroll < 0 then 
  884. 		scrolling_item = 0 
  885. 	elseif idx > max_items then 
  886. 		scrolling_item = max_items - CELLPHONE_BOOK_TOP_LOCK 
  887. 	end 
  888.  
  889. 	-- Index of the highlighted item * The area height (minus the bar height, to account for the space it takes) / The amount of actual items the bar scrolls on 
  890. 	local position = (scrolling_item * (SCROLLBAR_MAX_HEIGHT - height)) / (max_items - CELLPHONE_BOOK_TOP_LOCK) 
  891. 	 
  892. 	local scrollbar_is_visible 
  893. 		 
  894. 	if menu_data.num_items >= DISPLAY_MAX_ITEMS then 
  895. 		scrollbar_is_visible = true 
  896. 	else 
  897. 		scrollbar_is_visible = false 
  898. 	end 
  899. 	 
  900. 	-- Put it in the oven for baby and me. 
  901. 	--Update scrollbar 
  902. 	local scrollbar_h = Cellphone.menu_active.handles.scrollbar 
  903. 	element_set_actual_size(scrollbar_h, 8, height) 
  904. 	vint_set_property(scrollbar_h, "anchor", 0, position) 
  905. 	vint_set_property(scrollbar_h, "visible", scrollbar_is_visible) 
  906. 	 
  907. 	local slide_y = 0 
  908. 	if idx < CELLPHONE_BOOK_TOP_LOCK then 
  909. 		--Lock to top 
  910. 		slide_y = 0 
  911. 	elseif idx > bottom_lock then 
  912. 		--Lock to bottom 
  913. 		slide_y = bottom_lock_locker * - line_height 
  914. 	else 
  915. 		--Nav normally 
  916. 		slide_y = (idx -  CELLPHONE_BOOK_TOP_LOCK) * - line_height	 
  917. 	end 
  918. 	 
  919. 	if menu_data.num_items < DISPLAY_MAX_ITEMS then 
  920. 		--Do not scroll if the items are less than what can be displayed on the screen 
  921. 		return 
  922. 	end 
  923. 	 
  924. 	--TODO: Occlude/show items 
  925. 	local item_min = idx - CELLPHONE_MAX_PHONEBOOK_NUMBERS 
  926. 	local item_max = idx + CELLPHONE_MAX_PHONEBOOK_NUMBERS 
  927. 	if item_min < 0 then 
  928. 		item_min = 0 
  929. 	end 
  930. 	if item_max > menu_data.num_items - 1 then 
  931. 		item_max = menu_data.num_items - 1 
  932. 	end 
  933. 	 
  934. 	--Occlude items 
  935. 	for i = 0, menu_data.num_items - 1 do 
  936. 		if i < item_min or i > item_max then 
  937. 		 
  938. 			if menu_data[i].grp_h ~= -1 then 
  939. 				--Remove if it exists 
  940. 				cellphone_phonebook_remove_from_list(i) 
  941. 			end 
  942. 		end 
  943. 	end 
  944.  
  945. 	--Make sure all the items are visible 
  946. 	for i = 0, menu_data.num_items - 1 do 
  947. 		if i >= item_min and i <= item_max then 
  948. 			if menu_data[i].grp_h == -1 then 
  949. 				--Add item if it doesn't exist 
  950. 				cellphone_phonebook_add_to_list(i) 
  951. 			end 
  952. 		end 
  953. 	end 
  954. 	 
  955. 	--Slide menu 
  956. 	local slide_box = vint_object_find("book_slider", menu_data.handles.grp) 
  957. 	local x, y = vint_get_property(slide_box, "anchor") 
  958. 	vint_set_property(Cellphone.handles.book_slider_tween, "start_value", x, y) 
  959. 	vint_set_property(Cellphone.handles.book_slider_tween, "end_value", 0, slide_y) 
  960. 	vint_set_property(Cellphone.handles.book_slider_tween, "target_handle", slide_box) 
  961. 	lua_play_anim(Cellphone.handles.book_slider_anim, 0) 
  962. end 
  963.  
  964. function cellphone_phonebook_nav_end() 
  965. 	--Block input 
  966. 	cellphone_nav_block(false) 
  967. end 
  968.  
  969. function cellphone_phonebook_align() 
  970. 	local menu_data = Cellphone.menu_active 
  971. 	 
  972. 	if menu_data.num_items == 0 then 
  973. 		--No items so there is nothing to align 
  974. 		return 
  975. 	end 
  976. 	 
  977. 	local h, x, y, width, height 
  978. 	local menu_item, old_h, text_h, text_x, text_y  
  979.  
  980. 	for i = 0, menu_data.num_items - 1 do 
  981. 		menu_item = menu_data[i] 
  982. 		if old_h ~= nil and menu_item.grp_h ~= -1 and old_h ~= -1 then 
  983. 			--Get Previous text size 
  984. 			text_h = vint_object_find("book_item_text", old_h) 
  985. 			text_x, text_y = vint_get_property(text_h, "anchor") 
  986. 			local text_string = vint_get_property(text_h, "text_tag") 
  987. 			if text_string ~= nil then 
  988. 				width, height = element_get_actual_size(text_h) 
  989. 				x, y = vint_get_property(old_h, "anchor") 
  990. 			 
  991. 				y = y + text_y + height 
  992. 				vint_set_property(menu_item.grp_h, "anchor", x, y) 
  993. 			end 
  994. 		end 
  995. 		old_h = menu_item.grp_h  
  996. 	end 
  997. 	old_h = nil 
  998. end 
  999.  
  1000. function cellphone_phonebook_add_to_list(idx) 
  1001. 		local menu_data = Cellphone.menu_active 
  1002. 		 
  1003. 		local menu_item_h = vint_object_find("book_item", menu_data.handles.grp)	 
  1004. 		local h, x, y, width, height 
  1005. 		local menu_item, old_h, text_h, bmp_h, text_x, text_y  
  1006. 		 
  1007. 		local item_spacing = 0 
  1008. 		menu_item = menu_data[idx] 
  1009. 		 
  1010. 		local contact_text_tag = "" 
  1011. 		 
  1012. 		menu_item.grp_h = vint_object_clone(menu_item_h) 
  1013. 		vint_set_property(menu_item.grp_h , "visible", true) 
  1014. 		 
  1015. 		--Is the item on the top or bottom of the list? 
  1016. 		if idx == 0 then 
  1017. 			-- this is the first item in the list 
  1018. 			vint_set_property(menu_item.grp_h, "anchor", 0, 0) 
  1019. 		elseif menu_data[idx - 1].grp_h == -1 and idx + 1 ~= menu_data.num_items then 
  1020. 			--This is on the top but not the first item and not the last item 
  1021. 			old_h = menu_data[idx + 1].grp_h 
  1022. 			text_h = vint_object_find("book_item_text", old_h) 
  1023. 			text_x, text_y = vint_get_property(text_h, "anchor") 
  1024. 			local text_string = vint_get_property(text_h, "text_tag") 
  1025. 			--debug_print("vint", "text10: " .. var_to_string(text_string)  .. "\n") 
  1026. 			if text_string ~= nil then 
  1027. 				width, height = element_get_actual_size(text_h) 
  1028. 				x, y = vint_get_property(old_h, "anchor") 
  1029. 				y = y - text_y - height - item_spacing 
  1030. 				vint_set_property(menu_item.grp_h, "anchor", x, y) 
  1031. 			end 
  1032.  
  1033. 		end 
  1034. 		--Does it even matter where the item is? haha but we need to initialize it 
  1035.  
  1036. 		 
  1037. 		--Change text on elements 
  1038. 		text_h = vint_object_find("book_item_text", menu_item.grp_h) 
  1039. 		if menu_item.is_active == true then 
  1040. 			local values = { [0] = menu_item.contact_name} 
  1041. 			contact_text_tag = vint_insert_values_in_string("CELL_CHEAT_OPTION_ACTIVE", values) 
  1042. 		else 
  1043. 			contact_text_tag  = menu_item.contact_name 
  1044. 		end	 
  1045. 		vint_set_property(text_h, "text_tag", contact_text_tag) 
  1046. 		 
  1047. 		--Change bitmaps if we use an image peg 
  1048. 		if menu_data.image_peg ~= -1 then 
  1049. 			bmp_h = vint_object_find("book_image", menu_item.grp_h) 
  1050. 			vint_set_property(bmp_h, "image_crc", menu_item.bmp_crc) 
  1051. 		end 
  1052. 		 
  1053. 		--Need to initialize all the elements 
  1054. 		--i.e. make them all one line 
  1055. 		 
  1056. 		--Image size 
  1057. 		h = vint_object_find("book_image", menu_item.grp_h) 
  1058. 		width, height = vint_get_property(h, "source_se") 
  1059. 		height = 0 
  1060. 		vint_set_property(h, "source_se", width, height) 
  1061. 		vint_set_property(h, "alpha", 0) 
  1062. 		x, y = vint_get_property(text_h, "anchor") 
  1063. 		y = 0 
  1064. 		vint_set_property(text_h, "anchor", x, y) 
  1065. 		 
  1066. 		local text_string = vint_get_property(text_h, "text_tag") 
  1067. 		 
  1068. 		if text_string ~= nil then 
  1069. 			cellphone_phonebook_resize_static_text(text_h, 1.0, false) 
  1070. 		end 
  1071. 		 
  1072. 		vint_set_property(text_h, "tint", 0.1294, 0.1765, 0.204) 
  1073. 		vint_set_property(text_h, "alpha", 1) 
  1074. end 
  1075.  
  1076. function cellphone_phonebook_remove_from_list(idx) 
  1077. 	local menu_data = Cellphone.menu_active 
  1078. 	local menu_item = menu_data[idx] 
  1079. 	vint_object_destroy(menu_item.grp_h) 
  1080. 	menu_item.grp_h = -1 
  1081. end 
  1082.  
  1083. function cellphone_phonebook_call() 
  1084. 	local menu_data = Cellphone.menu_active 
  1085.  
  1086. 	if menu_data.num_items == 0 then 
  1087. 		--not allowed to call if nobody to talk too... 
  1088. 		return 
  1089. 	end 
  1090. 	 
  1091. 	local index = menu_data[menu_data.cur_idx].index 
  1092. 	 
  1093. 	--Set strings for call 
  1094. 	Cellphone.number_called = menu_data[menu_data.cur_idx].contact_name 
  1095. 	 
  1096. 	cellphone_menu_show(Cellphone_menu_call) 
  1097. 	 
  1098. 	--Place call to C and arrange callbacks 
  1099. 	cellphone_dial(menu_data.book_type, index, "cellphone_dial_connection_cb", "cellphone_call_hangup") 
  1100. 	 
  1101. 	--Play Data Entry sound 
  1102. 	audio_play(Cellphone_audio["data_entry"])	 
  1103. end 
  1104.  
  1105.  
  1106. function cellphone_phonebook_cleanup() 
  1107. 	--Remove all objects associated with the  current phonebook 
  1108. 	--This is a pretty shameful hack because we only support one instance of the phonebook... 
  1109. 	 
  1110. 	--Pause All animations 
  1111. 	vint_set_property(Cellphone.handles.book_slider_anim, "is_paused", true) 
  1112. 	vint_set_property(Cellphone.handles.book_text_select_anim, "is_paused", true) 
  1113. 	vint_set_property(Cellphone.handles.book_text_deselect_anim, "is_paused", true) 
  1114. 	vint_set_property(Cellphone.handles.book_image_select_anim, "is_paused", true) 
  1115. 	vint_set_property(Cellphone.handles.book_image_deselect_anim, "is_paused", true) 
  1116. 	vint_object_destroy(Cellphone.menu_inactive.handles.grp) 
  1117. 	 
  1118. 	if cellphone_nav_is_blocked() == true then 
  1119. 		cellphone_nav_block(false) 
  1120. 	end 
  1121. 	 
  1122. 	if Cellphone_phonebook_thread ~= -1 then 
  1123. 		thread_kill(Cellphone_phonebook_thread) 
  1124. 		Cellphone_phonebook_thread = -1 
  1125. 	end 
  1126. end 
  1127.  
  1128. function cellphone_phonebook_populate(contact_name, bmp_crc, description, index) 
  1129. 	local menu_data = Cellphone.menu_active 
  1130. 	local idx = menu_data.num_items 
  1131. 	menu_data[idx] = {contact_name = contact_name, bmp_crc = bmp_crc, description = description, index = index} 
  1132. 	menu_data.num_items = menu_data.num_items + 1 
  1133. end 
  1134.  
  1135. function cellphone_phonebook_populate_cheats(contact_name, description, is_active, index, doesnt_flag_cheat) 
  1136. 	--Populate Cheat 
  1137. 	local menu_data = Cellphone.menu_active 
  1138. 	local idx = menu_data.num_items 
  1139. 	menu_data[idx] = {index = index, contact_name = contact_name, description = description, is_active = is_active, doesnt_flag_cheat = doesnt_flag_cheat} 
  1140. 	menu_data.num_items = menu_data.num_items + 1 
  1141. end 
  1142.  
  1143. function cellphone_phonebook_populate_garage(index, vehicle_name, repair_cost) 
  1144. 	--Populate Garage List 
  1145. 	local menu_data = Cellphone.menu_active 
  1146. 	local idx = menu_data.num_items 
  1147. 	menu_data[idx] = {index = index, contact_name = vehicle_name, repair_cost = repair_cost} 
  1148. 	menu_data.num_items = menu_data.num_items + 1 
  1149. end 
  1150.  
  1151. function cellphone_garage_get_car() 
  1152. 	local menu_data = Cellphone.menu_active 
  1153. 	 
  1154. 	if menu_data.num_items == 0 then 
  1155. 		--not cars available if no cars available too... 
  1156. 		return 
  1157. 	end 
  1158.  
  1159. 	--Play Audio 
  1160. 	audio_play(Cellphone_audio["data_entry"])	 
  1161. 	 
  1162. 	--Called when selecting an option from the garage 
  1163. 	local repair_cost = menu_data[menu_data.cur_idx].repair_cost  
  1164. 	 
  1165. 	--Check if player has enough cash 
  1166. 	if Cellphone.player_cash < repair_cost then 
  1167. 		--Not enough cash dialog 
  1168. 		dialog_box_message("CELL_VEHICLE_DIALOG_NO_CASH_HEADER","CELL_VEHICLE_DIALOG_NO_CASH_BODY") 
  1169. 		return 
  1170. 	end 
  1171.  
  1172. 	--Repair and Deliver if player has enough cash. 
  1173. 	if repair_cost == 0 then 
  1174. 		--Deliver if repair price = 0 
  1175. 		cellphone_choose_vehicle(menu_data[menu_data.cur_idx].index) 
  1176. 		cellphone_menu_show(Cellphone_menu_main) 
  1177. 		return 
  1178. 	end 
  1179. 	 
  1180. 	--Car needs repairs, prepare localized dialog and display 
  1181. 	 
  1182. 	if repair_cost ~= 0 then 
  1183. 		local values = {[0] = repair_cost} 
  1184. 		local dialog_repairs_body = vint_insert_values_in_string("CELL_VEHICLE_DIALOG_REPAIRS_BODY", values) 
  1185. 		dialog_box_confirmation("CELL_VEHICLE_DIALOG_REPAIRS_HEADER", dialog_repairs_body, "cellphone_garage_get_car_dialog_cb") 
  1186. 	else  
  1187. 		local index = Cellphone.menu_active[Cellphone.menu_active.cur_idx].index 
  1188. 		cellphone_choose_vehicle(index) 
  1189. 		cellphone_menu_show(Cellphone_menu_main) 
  1190. 	end 
  1191. end 
  1192.  
  1193. function cellphone_garage_get_car_dialog_cb(result, action) 
  1194. 	if action ~= DIALOG_ACTION_CLOSE then 
  1195. 		return 
  1196. 	end 
  1197. 	if result == 0 then 
  1198. 		local index = Cellphone.menu_active[Cellphone.menu_active.cur_idx].index 
  1199. 		cellphone_choose_vehicle(index) 
  1200. 	end 
  1201. 	 
  1202. 	cellphone_menu_show(Cellphone_menu_main) 
  1203. end 
  1204.  
  1205. function cellphone_garage_get_car_dialog() 
  1206. end 
  1207.  
  1208. ------------------------------------- 
  1209. --Dial 
  1210. ------------------------------------- 
  1211. function cellphone_dial_show() 
  1212. 	local menu_data = Cellphone.menu_active 
  1213. 	 
  1214. 	--Show Subheader 
  1215. 	 cellphone_subheader_show(menu_data.header_string) 
  1216. 	--Show controls 
  1217. 	 
  1218. 	--Initialize Control 
  1219. 	menu_data.dial_number = {} 
  1220. 	menu_data.dial_number_dirty_digits = 0 
  1221. 	menu_data.dial_number_digits = 0 
  1222. 	menu_data.dial_number_string = "" 
  1223. 	menu_data.cur_idx = 0 
  1224. 	menu_data.cur_row = 0 
  1225. 	menu_data.cur_col = 0 
  1226. 	 
  1227. 	--Clear out dial part 
  1228. 	vint_set_property(Cellphone_menu_dial.handles.dial_number, "text_tag", "") 
  1229. 	 
  1230. 	--dim out all the buttons 
  1231. 	for i=0, menu_data.num_items -1 do 
  1232. 		cellphone_dial_btn_dim(menu_data[i].h) 
  1233. 	end 
  1234. 	cellphone_dial_btn_bright(menu_data[0].h) 
  1235. end 
  1236.  
  1237. function cellphone_dial_select() 
  1238. 	local menu_data = Cellphone.menu_active 
  1239. 	 
  1240. 	--What button was pressed 
  1241. 	local btn_pressed = menu_data[menu_data.cur_idx] 
  1242. 	local update_number = true 
  1243. 	 
  1244. 	if btn_pressed.btn_type == "call" then 
  1245. 		--Return if there is no number to call 
  1246. 		if menu_data.dial_number_digits == 0 then 
  1247. 			return 
  1248. 		end 
  1249. 		 
  1250. 		--Store the dial string to global 
  1251. 		Cellphone.number_called = menu_data.dial_number_string 
  1252. 		 
  1253. 		--Probably need to store some data somewhere for the call part 
  1254. 		cellphone_menu_show(Cellphone_menu_call) 
  1255. 		 
  1256. 		local dial_string = "" 
  1257. 		for i=0, menu_data.dial_number_digits - 1 do 
  1258. 			dial_string = dial_string .. menu_data.dial_number[i] 
  1259. 		end 
  1260. 		 
  1261. 		 
  1262. 		--Place call to C and arrange callbacks 
  1263. 		cellphone_dial_number(dial_string, "cellphone_dial_connection_cb", "cellphone_call_hangup") 
  1264. 		update_number = false 
  1265. 		 
  1266. 		--play data entry sounds 
  1267. 		audio_play(Cellphone_audio["data_entry"])	 
  1268. 	elseif btn_pressed.btn_type  == "clr" then 
  1269. 		--Check if number was dirty 
  1270. 		local num = menu_data.dial_number[menu_data.dial_number_digits - 1] 
  1271. 		if num == "#" or num == "*" then  
  1272. 			menu_data.dial_number_dirty_digits = menu_data.dial_number_dirty_digits -1  
  1273. 		end 
  1274. 		 
  1275. 		menu_data.dial_number_digits = menu_data.dial_number_digits - 1 
  1276. 		if menu_data.dial_number_digits <= 0 then 
  1277. 			menu_data.dial_number_digits = 0 
  1278. 		end 
  1279. 		 
  1280. 		--play clear sounds 
  1281. 		audio_play(Cellphone_audio["data_entry"])	 
  1282. 	else 
  1283. 		if menu_data.dial_number_digits == menu_data.dial_number_max_digits then 
  1284. 			--No more key pressing! 
  1285. 			return 
  1286. 		end 
  1287. 		--Standard Key was pressed 
  1288. 		 
  1289. 		--Dirty digit was pressed 
  1290. 		if btn_pressed.btn_type == "pound" or btn_pressed.btn_type == "star" then 
  1291. 			menu_data.dial_number_dirty_digits = menu_data.dial_number_dirty_digits + 1 
  1292. 			--Play off key sound. 
  1293. 			audio_play(Cellphone_audio[btn_pressed.btn_type])	 
  1294. 		else 
  1295. 			--Play key sound. 
  1296. 			audio_play(Cellphone_audio[btn_pressed.id])	 
  1297. 		end 
  1298. 		 
  1299. 		 
  1300. 		 
  1301. 		menu_data.dial_number[menu_data.dial_number_digits] = btn_pressed.id 
  1302. 		menu_data.dial_number_digits = menu_data.dial_number_digits + 1 
  1303. 	end 
  1304. 	 
  1305. 	--Update the number in the display window 
  1306. 	if update_number == true then 
  1307. 		local do_formatting = true 
  1308. 		menu_data.dial_number_string = "" 
  1309. 		for i=0, menu_data.dial_number_digits - 1 do 
  1310. 		 
  1311. 			if menu_data.dial_number_digits > 10 or menu_data.dial_number_dirty_digits > 0 then 
  1312. 				--No Formatting 
  1313. 			elseif menu_data.dial_number_digits >= 8 then 
  1314. 				--Area Code Style String 
  1315. 				if i == 0 then 
  1316. 					menu_data.dial_number_string = "(" 
  1317. 				end 
  1318. 				if i == 3 then 
  1319. 					menu_data.dial_number_string = menu_data.dial_number_string .. ") " 
  1320. 				end 
  1321. 				if i == 6 then 
  1322. 					menu_data.dial_number_string = menu_data.dial_number_string .. "-" 
  1323. 				end 
  1324. 			else 
  1325. 				--Local Number String 
  1326. 				if i==3 or i==7 then 
  1327. 					menu_data.dial_number_string = menu_data.dial_number_string .. "-" 
  1328. 				end 
  1329. 			end 
  1330. 			menu_data.dial_number_string = menu_data.dial_number_string .. menu_data.dial_number[i] 
  1331. 		end	 
  1332. 		--update Number 
  1333. 		vint_set_property(Cellphone_menu_dial.handles.dial_number, "text_tag", menu_data.dial_number_string) 
  1334. 	end 
  1335. end 
  1336.  
  1337. function cellphone_dial_nav_left() 
  1338. 	local menu_data = Cellphone.menu_active 
  1339. 	local col = menu_data.cur_col 
  1340. 	 
  1341. 	col = col - 1 
  1342. 	if col < 0 then 
  1343. 		col = menu_data.num_cols - 1 
  1344. 	end 
  1345.  
  1346. 	--menu_grid_update_highlighted(menu_data, col, menu_data.cur_row) 
  1347. 	cellphone_dial_update_highlighted(col, menu_data.cur_row) 
  1348. 	audio_play(Cellphone_audio["nav"]) 
  1349. end 
  1350.  
  1351. function cellphone_dial_nav_right() 
  1352. 	local menu_data = Cellphone.menu_active 
  1353. 	local col = menu_data.cur_col 
  1354.  
  1355. 	col = col + 1 
  1356. 	if col > menu_data.num_cols - 1 then 
  1357. 		col = 0 
  1358. 	end 
  1359. 	cellphone_dial_update_highlighted(col, menu_data.cur_row) 
  1360. 	audio_play(Cellphone_audio["nav"]) 
  1361. end 
  1362.  
  1363. function cellphone_dial_nav_up() 
  1364. 	local menu_data = Cellphone.menu_active 
  1365. 	local row = menu_data.cur_row 
  1366.  
  1367. 	row = row - 1 
  1368. 	if row < 0 then 
  1369. 		row = menu_data.num_rows - 1 
  1370. 	end 
  1371.  
  1372. 	--menu_grid_update_swatches(menu_data, row) 
  1373. 	cellphone_dial_update_highlighted(menu_data.cur_col, row) 
  1374. 	audio_play(Cellphone_audio["nav"]) 
  1375. end 
  1376.  
  1377. function cellphone_dial_nav_down() 
  1378. 	local menu_data = Cellphone.menu_active 
  1379. 	local row = menu_data.cur_row 
  1380.  
  1381. 	row = row + 1 
  1382. 	if row > menu_data.num_rows - 1 then 
  1383. 		row = 0 
  1384. 	end 
  1385.  
  1386. 	--	menu_grid_update_swatches(menu_data, row) 
  1387. 	cellphone_dial_update_highlighted(menu_data.cur_col, row) 
  1388. 	audio_play(Cellphone_audio["nav"]) 
  1389. end 
  1390.  
  1391. function cellphone_dial_update_highlighted(new_col, new_row) 
  1392. 	local menu_data = Cellphone.menu_active 
  1393. 	local new_idx = new_row * menu_data.num_cols + new_col 
  1394. 	local old_idx = menu_data.cur_row * menu_data.num_cols + menu_data.cur_col 
  1395. 	if new_idx >= menu_data.num_items then 
  1396. 		return 
  1397. 	end 
  1398. 	 
  1399. 	local idx = new_row * menu_data.num_cols + new_col 
  1400.  
  1401. 	--Skip extra call button 
  1402. 	if (old_idx ~= 0 and idx == 1) then	 
  1403. 		idx = 0 
  1404. 		new_row = 0 
  1405. 		new_col = 0 
  1406. 	elseif (old_idx == 0 and idx == 1) then 
  1407. 		idx = 2 
  1408. 		new_row = 0 
  1409. 		new_col = 2 
  1410. 	end 
  1411. 	 
  1412. 	--highlight new and darken old 
  1413. 	cellphone_dial_btn_bright(menu_data[idx].h) 
  1414. 	cellphone_dial_btn_dim(menu_data[old_idx].h) 
  1415. 	 
  1416. 	 
  1417. 	--Update global menu data 
  1418. 	menu_data.cur_row = new_row 
  1419. 	menu_data.cur_col = new_col 
  1420. 	menu_data.cur_idx = idx 
  1421. end 
  1422.  
  1423. function cellphone_dial_btn_dim(item_h) 
  1424. 	--Set button state to dim 
  1425. 	local h 
  1426. 	h = vint_object_find("selected", item_h) 
  1427. 	vint_set_property(h, "alpha", 0) 
  1428. 	 
  1429. 	h = vint_object_find("unselected", item_h) 
  1430. 	vint_set_property(h, "alpha", 1) 
  1431. 	 
  1432. 	h = vint_object_find("number", item_h) 
  1433. 	if h ~= 0 then 
  1434. 		vint_set_property(h, "tint", 0.1529, 0.3216, 0.424) 
  1435. 		 
  1436. 	end 
  1437. 	 
  1438. 	h = vint_object_find("extra_text", item_h) 
  1439. 	if h ~= 0 then 
  1440. 		vint_set_property(h, "tint", 0.1529, 0.3216, 0.424) 
  1441. 	end 
  1442. 	 
  1443. 	vint_set_property(item_h, "alpha", .5) 
  1444. end 
  1445.  
  1446. function cellphone_dial_btn_bright(item_h) 
  1447. 	--Set button state to highlight 
  1448. 	local h 
  1449. 	h = vint_object_find("selected", item_h) 
  1450. 	vint_set_property(h, "alpha", 1) 
  1451. 	 
  1452. 	h = vint_object_find("unselected", item_h) 
  1453. 	vint_set_property(h, "alpha", 0) 
  1454.  
  1455. 	h = vint_object_find("number", item_h) 
  1456. 	if h ~= 0 then 
  1457. 		vint_set_property(h, "tint", 0.3608, 0.6353, 0.764) 
  1458. 	end 
  1459. 	 
  1460. 	h = vint_object_find("extra_text", item_h) 
  1461. 	if h ~= 0 then 
  1462. 		vint_set_property(h, "tint", 0.3608, 0.6353, 0.764) 
  1463. 	end 
  1464. 	 
  1465. 	vint_set_property(Cellphone.handles.dial_selected_twn, "target_handle", item_h) 
  1466. 	lua_play_anim(Cellphone.handles.dial_selected, 0) 
  1467. end 
  1468.  
  1469. function cellphone_dial_connection_cb(success, name, description) 
  1470.  
  1471. 	if success == -1 then 
  1472. 		--wrong number 
  1473. 		--use invalid number screen 
  1474. 		cellphone_call_connected(Cellphone.number_called) 
  1475. 	elseif success == 0 then 
  1476. 		--cheat unlocked 
  1477. 		--description = cheat description 
  1478. 		cellphone_cheat_added_show(name, description) 
  1479. 	elseif success == 1 then 
  1480. 		--Connection has been made, string of store name to display is stored in name 
  1481. 		cellphone_call_connected(name) 
  1482. 	elseif success == 2 then 
  1483. 		--Show garage Menu 
  1484. 		cellphone_menu_show(Cellphone_menu_garage) 
  1485. 	end 
  1486. end 
  1487.  
  1488. function cellphone_dial_exit() 
  1489. end 
  1490.  
  1491. ------------------------------------- 
  1492. --Calling 
  1493. ------------------------------------- 
  1494. function cellphone_call_show() 
  1495. 	 
  1496. 	--Set subheader to no title 
  1497. 	cellphone_subheader_show("") 
  1498. 	 
  1499. 	--Set Text fields to the number dialed 
  1500. 	vint_set_property(Cellphone.handles.call_number_1, "text_tag", Cellphone.number_called) 
  1501. 	vint_set_property(Cellphone.handles.call_number_2, "text_tag", Cellphone.number_called) 
  1502. 	 
  1503. 	--Resize text fields if they are too large 
  1504. 	vint_set_property(Cellphone.handles.call_number_2, "scale", 1, 1) 
  1505. 	local width, height = element_get_actual_size(Cellphone.handles.call_number_2) 
  1506. 	if width > 245 then 
  1507. 		local scale = 245/width 
  1508. 		vint_set_property(Cellphone.handles.call_number_2, "scale", scale, scale) 
  1509. 	end 
  1510. 	 
  1511. 	vint_set_property(Cellphone.handles.calling_grp, "alpha", 1) 
  1512. 	vint_set_property(Cellphone.handles.speaking_grp, "alpha", 0) 
  1513. 	 
  1514. 	--move dots 
  1515. 	local x, y = vint_get_property(Cellphone.handles.call_text, "anchor")  
  1516. 	local text_string = vint_get_property(Cellphone.handles.call_text, "text_tag") 
  1517. 	--debug_print("vint", "text5: " .. var_to_string(text_string)  .. "\n") 
  1518.  
  1519. 	if text_string ~= nil then 
  1520. 		local width, height = element_get_actual_size(Cellphone.handles.call_text) 
  1521. 		x = x + width + 2 
  1522. 		vint_set_property(Cellphone.handles.call_dots, "anchor", x,y) 
  1523. 	end 
  1524. 	 
  1525. 	vint_set_property(vint_object_find("dot1", Cellphone.handles.call_dots), "alpha", 0) 
  1526. 	vint_set_property(vint_object_find("dot2", Cellphone.handles.call_dots), "alpha", 0) 
  1527. 	vint_set_property(vint_object_find("dot3", Cellphone.handles.call_dots), "alpha", 0) 
  1528. 	 
  1529. 	--Play dot animations 
  1530. 	lua_play_anim(Cellphone.handles.calling_dot_anim, 0) 
  1531. end 
  1532.  
  1533. function cellphone_call_connected() 
  1534. 	--Calling to speak animation 
  1535. 	lua_play_anim(Cellphone.handles.calling_to_speak_anim, 0) 
  1536.  
  1537. 	--Stop dot animation 
  1538. 	vint_set_property(Cellphone.handles.calling_dot_anim, "is_paused", false) 
  1539. end 
  1540. function cellphone_call_hangup() 
  1541. 	cellphone_end_call() 
  1542. 	cellphone_menu_show(Cellphone_menu_main) 
  1543. end 
  1544.  
  1545. function cellphone_call_dot_loop() 
  1546. 	lua_play_anim(Cellphone.handles.calling_dot_anim, 0) 
  1547. end 
  1548.  
  1549. ------------------------------------- 
  1550. --Cheats 
  1551. ------------------------------------- 
  1552. function cellphone_cheat_cat_select() 
  1553. 	local idx = Cellphone.menu_active.cur_idx 
  1554. 	Cellphone.number_called = idx 
  1555. 	Cellphone_menu_cheat_spec.header_string = Cellphone_menu_cheat_cat[idx].contact_name 
  1556. 	cellphone_menu_show(Cellphone_menu_cheat_spec) 
  1557. 	 
  1558. 	--Play Data Entry sound 
  1559. 	audio_play(Cellphone_audio["data_entry"])	 
  1560. end 
  1561.  
  1562. function cellphone_cheat_spec_back() 
  1563. 	audio_play(Cellphone_audio["nav_back"]) 
  1564. 	cellphone_menu_show(Cellphone_menu_cheat_cat) 
  1565. end 
  1566.  
  1567. function cellphone_cheat_spec_select() 
  1568. 	--Do the dialog box question... 
  1569. 	local menu_data = Cellphone.menu_active 
  1570. 	 
  1571. 	local menu_item = menu_data[menu_data.cur_idx] 
  1572. 	 
  1573. 	if menu_data.num_items == 0 then 
  1574. 		--No calls allowed if no items are in the list 
  1575. 		return 
  1576. 	end 
  1577. 	 
  1578. 	--Store cheat data into globals for following screen 
  1579. 	Cellphone.cheat_selected_idx = menu_item.index 
  1580. 	Cellphone.cheat_selected_desc = menu_item.description 
  1581. 	Cellphone.number_called = menu_item.contact_name 
  1582. 	 
  1583. 	--Insert values 
  1584. 	local values = {[0] = menu_item.contact_name, [1] = menu_item.description} 
  1585. 	 
  1586. 	--Determine wheather we de activate or activeate 
  1587. 	local heading 
  1588. 	local body_tag 
  1589. 	if menu_item.is_active == false then 
  1590. 		heading = "CELL_CHEAT_ACTIVIATE_DIALOG_HEADER" 
  1591. 		body_tag = vint_insert_values_in_string("CELL_CHEAT_ACTIVIATE_DIALOG_BODY", values) 
  1592. 	 
  1593. 	else 
  1594. 		heading = "CELL_CHEAT_DEACTIVATE_DIALOG_HEADER" 
  1595. 		body_tag = vint_insert_values_in_string("CELL_CHEAT_DEACTIVATE_DIALOG_BODY", values) 
  1596. 	end 
  1597. 	 
  1598. 	if get_platform() == "PS3" or menu_item.doesnt_flag_cheat == true then 
  1599. 		--No acheivement warnings... activate/deactivate cheat 
  1600. 		local is_active = cellphone_activate_cheat(Cellphone.cheat_selected_idx) 
  1601. 		cellphone_cheat_activated_show(is_active) 
  1602. 	else 
  1603. 		--Acheivement warnings for 360 and PC 
  1604. 		dialog_box_confirmation(heading, body_tag, "cellphone_cheat_activation_cb") 
  1605. 	end 
  1606. end 
  1607.  
  1608. function cellphone_cheat_activation_cb(result, action) 
  1609. 	if action ~= DIALOG_ACTION_CLOSE then 
  1610. 		return 
  1611. 	end 
  1612. 	 
  1613. 	if result == 0 then 
  1614. 		--Activate cheat 
  1615. 		local is_active = cellphone_activate_cheat(Cellphone.cheat_selected_idx) 
  1616. 		 
  1617. 		--Now display the next menu 
  1618. 		cellphone_cheat_activated_show(is_active) 
  1619. 	else 
  1620. 		--do nothing 
  1621. 	end 
  1622. end 
  1623.  
  1624. function cellphone_cheat_added_show(name, description) 
  1625. 	--Added cheat...  
  1626. 	local desc_add_tag = "CELL_CHEAT_ACTIVATE_INSTRUCTIONS" 
  1627. 	 
  1628. 	local values = { [0] = description, [1] = "CELL_CHEAT_ACTIVATE_INSTRUCTIONS" } 
  1629. 	local desc_tag = vint_insert_values_in_string("{0}\n \n{1}", values) 
  1630. 	 
  1631. 	vint_set_property(Cellphone.handles.cheat_added_title, "text_tag", name) 
  1632. 	vint_set_property(Cellphone.handles.cheat_added_desc, "text_tag", desc_tag) 
  1633. 	cellphone_menu_show(Cellphone_menu_cheat_added) 
  1634. 	 
  1635. 	local text_string = vint_get_property(Cellphone.handles.cheat_added_title, "text_tag") 
  1636. 	--debug_print("vint", "text6: " .. var_to_string(text_string)  .. "\n") 
  1637. 	 
  1638. 	local gap = 0 
  1639. 	 
  1640. 	if text_string ~= nil then 
  1641. 		local title_w, title_h = element_get_actual_size(Cellphone.handles.cheat_added_title)	 
  1642. 		if title_h > 40 then 
  1643. 			gap = 60 
  1644. 		end 
  1645. 	end	 
  1646. 	 
  1647. 	local desc_x, desc_y = vint_get_property(Cellphone.handles.cheat_added_desc, "anchor") 
  1648. 	vint_set_property(Cellphone.handles.cheat_added_desc, "anchor", desc_x, desc_y + gap)  
  1649. 	 
  1650. 		--Play Added Sound 
  1651. 	audio_play(Cellphone_audio["cheat"])	 
  1652. end 
  1653.  
  1654. function cellphone_cheat_activated_show(is_active) 
  1655. 	--Update cheat information 
  1656. 	--Set activation type based on whether we are activating the cheat is active or not 
  1657. 	 
  1658. 	--Set Cheat type 
  1659. 	vint_set_property(Cellphone.handles.cheat_activated_title, "text_tag", Cellphone.number_called) 
  1660. 	 
  1661. 	local text_string = vint_get_property(Cellphone.handles.cheat_activated_title, "text_tag") 
  1662. 	--debug_print("vint", "text7: " .. var_to_string(text_string)  .. "\n") 
  1663. 	 
  1664. 	local gap = 0 
  1665. 	 
  1666. 	if text_string ~= nil then 
  1667. 		local title_w, title_h = element_get_actual_size(Cellphone.handles.cheat_activated_title) 
  1668.  
  1669. 		if title_h > 40 then 
  1670. 			gap = 60 
  1671. 		end 
  1672. 	end 
  1673. 	 
  1674. 	local state_x, state_y = vint_get_property(Cellphone.handles.cheat_activated_state, "anchor") 
  1675. 	local desc_x, desc_y = vint_get_property(Cellphone.handles.cheat_activated_desc, "anchor") 
  1676. 	 
  1677. 	vint_set_property(Cellphone.handles.cheat_activated_state, "anchor", state_x, state_y + gap)  
  1678. 	vint_set_property(Cellphone.handles.cheat_activated_desc, "anchor", desc_x, desc_y + gap)   
  1679. 	 
  1680. 	--Set text based on active state 
  1681. 	if is_active == true then 
  1682. 		vint_set_property(Cellphone.handles.cheat_activated_state, "text_tag", "CELL_HEADER_ACTIVATED")  
  1683. 		vint_set_property(Cellphone.handles.cheat_activated_desc, "text_tag", Cellphone.cheat_selected_desc)   
  1684. 	else 
  1685. 		vint_set_property(Cellphone.handles.cheat_activated_state, "text_tag", "CELL_HEADER_DEACTIVATED")  
  1686. 		vint_set_property(Cellphone.handles.cheat_activated_desc, "text_tag", "")   
  1687. 	end 
  1688. 	 
  1689. 	cellphone_menu_show(Cellphone_menu_cheat_activate) 
  1690. 	 
  1691. 	--Play Activate sound 
  1692. 	audio_play(Cellphone_audio["cheat"])	 
  1693. end    
  1694. ------------------------------------- 
  1695. --SUBHEADER 
  1696. ------------------------------------- 
  1697. function cellphone_subheader_show(header_string) 
  1698.  
  1699. 	if header_string == false then 
  1700. 		return 
  1701. 	end 
  1702. 		 
  1703. 	--Replace subheader string 
  1704. 	vint_set_property(Cellphone.handles.sub_header_text, "text_tag", header_string) 
  1705. 	 
  1706. 	if Cellphone.subheader_active == false then 
  1707. 		--Animate in 
  1708. 		vint_set_property(Cellphone.handles.sub_header, "alpha", 1) 
  1709. 		Cellphone.subheader_active = true 
  1710. 	end 
  1711. end 
  1712.  
  1713. function cellphone_subheader_hide() 
  1714. 	--Animate Out 
  1715. 	vint_set_property(Cellphone.handles.sub_header, "alpha", 0) 
  1716. 	 
  1717. 	Cellphone.subheader_active = false 
  1718. end 
  1719.  
  1720.  
  1721.  
  1722. ------------------------------------- 
  1723. --CLEANUP 
  1724. ------------------------------------- 
  1725. function cellphone_cleanup() 
  1726. 	cellphone_desubscribe_input() 
  1727. 	 
  1728. 	peg_unload("ui_cellphone") 
  1729. 	peg_unload("ui_cell_homies") 
  1730. 	 
  1731. 	--Unload our loaded peg in case we still have one loaded 
  1732. 	if Cellphone.loaded_peg ~= -1 then 
  1733. 		peg_unload(Cellphone.loaded_peg) 
  1734. 		Cellphone.loaded_peg = -1 
  1735. 	end 
  1736. 	 
  1737. 	--kill intro audio 
  1738. 	if Cellphone_intro_sound_thread ~= -1 then 
  1739. 		thread_kill(Cellphone_intro_sound_thread) 
  1740. 	end 
  1741. 	 
  1742. 	if Cellphone_intro_sound_instance ~= -1 then 
  1743. 		audio_fade_out(Cellphone_intro_sound_instance, .25) 
  1744. 	end 
  1745. end 
  1746.  
  1747. function cellphone_menu_sub_exit() 
  1748. 	audio_play(Cellphone_audio["nav_back"]) 
  1749. 	cellphone_menu_show(Cellphone_menu_main) 
  1750. end 
  1751.  
  1752. ------------------------------------- 
  1753. --UTILITY 
  1754. ------------------------------------- 
  1755. function cellphone_format_number(phone_number) 
  1756. 	local phone_string = "" 
  1757. 	local phone_temp = phone_number 
  1758. 	if phone_string >= 10000000000 then 
  1759. 		phone_number = phone_number 
  1760. 	else 
  1761. 		local p = 0 
  1762. 		local p_string = "" 
  1763. 		if phone_temp >= 10000000 then 
  1764. 			p = floor(phone_temp / 10000000) 
  1765. 			phone_string = "(" .. phone_string .. p .. ") " 
  1766. 			phone_temp = phone_temp - p * 10000000 
  1767. 		end 
  1768. 		if phone_temp >= 10000 then 
  1769. 			p = floor(phone_temp / 10000) 
  1770. 			phone_string = phone_string .. p .. "-" 
  1771. 			phone_temp = phone_temp - p * 10000 
  1772. 		end 
  1773. 		if cash_temp >= 0 then 
  1774. 			phone_string = phone_string .. phone_temp 
  1775. 		end 
  1776. 	end 
  1777. 	return phone_string	 
  1778. end 
  1779.  
  1780. --####################################### 
  1781. --Clock 
  1782. --####################################### 
  1783. function cellphone_clock_set() 
  1784.  
  1785. 	local hour, minute = cellphone_get_time() 
  1786. 	local pm = false 
  1787. 	if hour > 12 then 
  1788. 		hour = hour - 12 
  1789. 		pm = true 
  1790. 	end 
  1791. 	 
  1792. 	if hour == 12 then 
  1793. 		pm = true 
  1794. 	end 
  1795. 	 
  1796. 	local minute_str 
  1797. 	 
  1798. 	if minute < 10 then  
  1799. 		minute_str = "0" .. minute 
  1800. 	else 
  1801. 		minute_str = minute 
  1802. 	end 
  1803. 	 
  1804. 	local clock_time = hour .. ":" .. minute_str 
  1805. 	 
  1806. 	if pm == true then 
  1807. 		clock_time = clock_time .. " PM" 
  1808. 	else 
  1809. 		clock_time = clock_time .. " AM" 
  1810. 	end 
  1811. 	 
  1812. 	local time_h = vint_object_find("time_text") 
  1813. 	vint_set_property(time_h, "text_tag", clock_time) 
  1814. end 
  1815.  
  1816.  
  1817.  
  1818. --####################################### 
  1819. --Block navigation 
  1820. --####################################### 
  1821. function cellphone_nav_block(block) 
  1822. 	if block == true then 
  1823. 		Cellphone_nav_blocked = Cellphone_nav_blocked + 1 
  1824. 	else 
  1825. 		Cellphone_nav_blocked = Cellphone_nav_blocked - 1 
  1826. 	end 
  1827. end 
  1828.  
  1829. function cellphone_nav_is_blocked() 
  1830. 	return Cellphone_nav_blocked > 0 
  1831. end 
  1832.  
  1833. --####################################### 
  1834. --Background Animations 
  1835. --####################################### 
  1836.  
  1837. function cellphone_bg_anim_init() 
  1838. 	--hide bg anim peices 
  1839. 	local h 
  1840. 	h = vint_object_find("bg_p_1") 
  1841. 	vint_set_property(h, "alpha", 0) 
  1842. 	h = vint_object_find("bg_p_2") 
  1843. 	vint_set_property(h, "alpha", 0) 
  1844. 	h = vint_object_find("bg_p_3") 
  1845. 	vint_set_property(h, "alpha", 0) 
  1846. 	h = vint_object_find("bg_p_4") 
  1847. 	vint_set_property(h, "alpha", 0) 
  1848. 	h = vint_object_find("bg_p_5") 
  1849. 	vint_set_property(h, "alpha", 0) 
  1850. 	h = vint_object_find("bg_s_1") 
  1851. 	vint_set_property(h, "alpha", 0) 
  1852. 	h = vint_object_find("bg_s_2") 
  1853. 	vint_set_property(h, "alpha", 0) 
  1854. 	h = vint_object_find("bg_s_3") 
  1855. 	vint_set_property(h, "alpha", 0) 
  1856. 	h = vint_object_find("bg_s_4") 
  1857. 	vint_set_property(h, "alpha", 0) 
  1858. 	h = vint_object_find("bg_s_5") 
  1859. 	vint_set_property(h, "alpha", 0) 
  1860. 	 
  1861. 	--Anims 
  1862. 	Cellphone.bg_num_anims = 10 
  1863. 	local p_1_anim = vint_object_find("bg_p_1_anim_1") 
  1864. 	local p_2_anim = vint_object_find("bg_p_2_anim_1") 
  1865. 	local p_3_anim = vint_object_find("bg_p_3_anim_1") 
  1866. 	local p_4_anim = vint_object_find("bg_p_4_anim_1") 
  1867. 	local p_5_anim = vint_object_find("bg_p_5_anim_1") 
  1868. 	local s_1_anim = vint_object_find("bg_s_1_anim_1") 
  1869. 	local s_2_anim = vint_object_find("bg_s_2_anim_1") 
  1870. 	local s_3_anim = vint_object_find("bg_s_3_anim_1") 
  1871. 	local s_4_anim = vint_object_find("bg_s_4_anim_1") 
  1872. 	local s_5_anim = vint_object_find("bg_s_5_anim_1") 
  1873. 	 
  1874. 	--last tweens 
  1875. 	local p_1_twn = vint_object_find("bg_p_1_alpha_twn_2") 
  1876. 	local p_2_twn = vint_object_find("bg_p_2_alpha_twn_2") 
  1877. 	local p_3_twn = vint_object_find("bg_p_3_alpha_twn_2") 
  1878. 	local p_4_twn = vint_object_find("bg_p_4_alpha_twn_2") 
  1879. 	local p_5_twn = vint_object_find("bg_p_5_alpha_twn_2") 
  1880. 	local s_1_twn = vint_object_find("bg_s_1_alpha_twn_2") 
  1881. 	local s_2_twn = vint_object_find("bg_s_2_alpha_twn_2") 
  1882. 	local s_3_twn = vint_object_find("bg_s_3_alpha_twn_2") 
  1883. 	local s_4_twn = vint_object_find("bg_s_4_alpha_twn_2") 
  1884. 	local s_5_twn = vint_object_find("bg_s_5_alpha_twn_2") 
  1885.  
  1886. 	Cellphone.bg_anims = { 
  1887. 		[p_1_twn] = p_1_anim, 
  1888. 		[p_2_twn] = p_2_anim, 
  1889. 		[p_3_twn] = p_3_anim, 
  1890. 		[p_4_twn] = p_4_anim, 
  1891. 		[p_5_twn] = p_5_anim, 
  1892. 		[s_1_twn] = s_1_anim, 
  1893. 		[s_2_twn] = s_2_anim, 
  1894. 		[s_3_twn] = s_3_anim, 
  1895. 		[s_4_twn] = s_4_anim, 
  1896. 		[s_5_twn] = s_5_anim, 
  1897. 	} 
  1898. 	 
  1899. 	Cellphone.bg_anims_indexed = { 
  1900. 		[0] = p_1_anim, 
  1901. 		[1] = p_2_anim, 
  1902. 		[2] = p_3_anim, 
  1903. 		[3] = p_4_anim, 
  1904. 		[4] = p_5_anim, 
  1905. 		[5] = s_1_anim, 
  1906. 		[6] = s_2_anim, 
  1907. 		[7] = s_3_anim, 
  1908. 		[8] = s_4_anim, 
  1909. 		[9] = s_5_anim, 
  1910. 	}         
  1911. 	 
  1912. 	Cellphone.bg_anims_active = {} 
  1913. 	--Pause all Anims 
  1914. 	for idx, val in Cellphone.bg_anims_indexed do 
  1915. 		vint_set_property(val, "is_paused", true) 
  1916. 	end 
  1917. 	 
  1918. 	--Set tween callbacks 
  1919. 	for idx, val in Cellphone.bg_anims do 
  1920. 		vint_set_property(idx, "end_event", "cellphone_bg_anim_twn_end") 
  1921. 	end 
  1922.  
  1923. 	cellphone_bg_anim_random_play(0) 
  1924. 	cellphone_bg_anim_random_play(4) 
  1925. 	cellphone_bg_anim_random_play(8) 
  1926. 	cellphone_bg_anim_random_play(12) 
  1927. 	cellphone_bg_anim_random_play(16) 
  1928. end 
  1929.  
  1930. function cellphone_bg_anim_random_play(time_offset) 
  1931. 	local random_anim_idx, anim_h 
  1932. 	local anim_not_playing = false 
  1933. 	 
  1934. 	--Select random animation until we find one that isn't already playing 
  1935. 	local prevent_infinite = 0 
  1936. 	while true do 
  1937. 		random_anim_idx = rand_int(0, Cellphone.bg_num_anims - 1) 
  1938. 		anim_h = Cellphone.bg_anims_indexed[random_anim_idx] 
  1939. 		if Cellphone.bg_anims_active[anim_h] == nil then 
  1940. 			break 
  1941. 		end 
  1942. 		prevent_infinite = prevent_infinite + 1 
  1943. 		if prevent_infinite == Cellphone.bg_num_anims then 
  1944. 			break 
  1945. 		end 
  1946. 	end 
  1947. 	 
  1948. 	--Play animation 
  1949. 	lua_play_anim(anim_h, time_offset) 
  1950. 	 
  1951. 	--Set animation to active 
  1952. 	Cellphone.bg_anims_active[anim_h] = true 
  1953. end 
  1954.  
  1955. function cellphone_bg_anim_twn_end(twn_h, event) 
  1956. 	local anim_h = Cellphone.bg_anims[twn_h]  
  1957.  
  1958. 	--Remove animation from playing animation list 
  1959. 	Cellphone.bg_anims_active[anim_h] = nil 
  1960. 	--Select another animation to play 
  1961. 	cellphone_bg_anim_random_play(0) 
  1962. end 
  1963.  
  1964. --####################################### 
  1965. --Player Cash Data 
  1966. --####################################### 
  1967. function cellphone_cash_update(di_h) 
  1968. 	local cash = vint_dataitem_get(di_h) 
  1969. 	Cellphone.player_cash = floor(cash) 
  1970. end 
  1971.  
  1972. --####################################### 
  1973. --Special Cell Audio functions 
  1974. --####################################### 
  1975. function cell_audio_play_delayed(sound_id, offset) 
  1976. 	Cellphone_intro_sound_thread = thread_new("audio_play_delayed_thread", sound_id, offset) 
  1977. end 
  1978.  
  1979. function audio_play_delayed_thread(sound_id, offset) 
  1980. 	delay(offset) 
  1981. 	Cellphone_intro_sound_instance = audio_play(sound_id) 
  1982. 	Cellphone_intro_sound_thread = -1 
  1983. end 
  1984.  
  1985.  
  1986. --####################################### 
  1987. --Button Tips 
  1988. --####################################### 
  1989.  
  1990. --####################################### 
  1991. --MENUS 
  1992. --####################################### 
  1993. Cellphone_menu_dial = { 
  1994. 	menu_type="dial", 
  1995. 	header_string = "", 
  1996. 	dial_number = {}, 
  1997. 	dial_number_max_digits = 18, 
  1998. 	dial_number_digits = 0, 
  1999. 	dial_number_dirty_digits = 0, 
  2000. 	dial_number_string = "", 
  2001. 	num_items = 0, 
  2002. 	handles = {}, 
  2003. 	cur_idx = 0, 
  2004. 	cur_row = 0, 
  2005. 	cur_col = 0, 
  2006. 	num_cols = 3, 
  2007. 	num_rows = 5, 
  2008. 	num_items = 0, 
  2009. 	on_select = cellphone_dial_select, 
  2010. 	on_nav_up = cellphone_dial_nav_up, 
  2011. 	on_nav_down = cellphone_dial_nav_down, 
  2012. 	on_nav_left = cellphone_dial_nav_left, 
  2013. 	on_nav_right = cellphone_dial_nav_right, 
  2014. 	on_back = cellphone_menu_sub_exit, 
  2015. } 
  2016.  
  2017. Cellphone_menu_call = { 
  2018. 	menu_type = "call", 
  2019. 	header_string = "", 
  2020. 	calling_string = "", 
  2021. 	handles = {}, 
  2022. 	on_select = cellphone_call_hangup, 
  2023. 	on_back = cellphone_call_hangup, 
  2024. 	cur_idx = 0, 
  2025. 	num_items = 1, 
  2026. 	[0] = {dummy_item = -1} 
  2027. } 
  2028.  
  2029.  
  2030. Cellphone_menu_homies = { 
  2031. 	menu_type = "phonebook", 
  2032. 	header_string = "CELL_OPTION_HOMIES", 
  2033. 	dynamic_menu = true, 
  2034. 	book_type = 0, 
  2035. 	num_items = 3, 
  2036. 	cur_idx = 0, 
  2037. 	handles = {}, 
  2038. 	image_peg = "ui_cell_homies", 
  2039. 	on_select = cellphone_phonebook_call, 
  2040. 	on_nav = cellphone_phonebook_nav, 
  2041. 	on_back = cellphone_menu_sub_exit, 
  2042. 	cleanup = cellphone_phonebook_cleanup, 
  2043. 	[0] = { contact_name = "Lisa Evans", contact_id = 53252, bmp_crc = "homie_x", grp_h = 0 }, 
  2044. 	[1] = { contact_name = "Kimberly Reyes", contact_id = 53252, bmp_crc = "homie_x", grp_h = 0  }, 
  2045. 	[2] = { contact_name = "Jack Cassity", contact_id = 53252, bmp_crc = "homie_x", grp_h = 0  }, 
  2046. } 
  2047.  
  2048. Cellphone_menu_garage = { 
  2049. 	menu_type = "phonebook", 
  2050. 	header_string = "CELL_HEADER_GARAGE", 
  2051. 	dynamic_menu = true, 
  2052. 	book_type = 4, 
  2053. 	num_items = 0, 
  2054. 	cur_idx = 0, 
  2055. 	handles = {}, 
  2056. 	image_peg = -1, 
  2057. 	on_select = cellphone_garage_get_car, 
  2058. 	on_nav = cellphone_phonebook_nav, 
  2059. 	on_back = cellphone_menu_sub_exit, 
  2060. 	cleanup = cellphone_phonebook_cleanup, 
  2061. 	[0] = { contact_name = "Lisa Evans", contact_id = 53252, bmp_crc = "homie_x", grp_h = 0 }, 
  2062. 	[1] = { contact_name = "Kimberly Reyes", contact_id = 53252, bmp_crc = "homie_x", grp_h = 0  }, 
  2063. 	[2] = { contact_name = "Jack Cassity", contact_id = 53252, bmp_crc = "homie_x", grp_h = 0  }, 
  2064. } 
  2065.  
  2066. Cellphone_menu_book = { 
  2067. 	menu_type = "phonebook", 
  2068. 	header_string = "CELL_OPTION_PHONEBOOK", 
  2069. 	dynamic_menu = true, 
  2070. 	cur_idx = 0, 
  2071. 	book_type = 1, 
  2072. 	num_items = 1,  
  2073. 	handles = {}, 
  2074. 	image_peg = -1, 
  2075. 	on_select = cellphone_phonebook_call, 
  2076. 	on_nav = cellphone_phonebook_nav, 
  2077. 	on_back = cellphone_menu_sub_exit, 
  2078. 	cleanup = cellphone_phonebook_cleanup, 
  2079. 	[0] = { contact_name = "Jonny Gat", contact_id =53252, bmp_crc = "homie_x" }, 
  2080. } 
  2081.  
  2082. Cellphone_menu_cheat_cat = { 
  2083. 	menu_type = "phonebook", 
  2084. 	header_string = "CELL_OPTION_CHEATS", 
  2085. 	dynamic_menu = false, 
  2086. 	book_type = 3, 
  2087. 	cur_idx = 0, 
  2088. 	num_items = 5,  
  2089. 	handles = {}, 
  2090. 	image_peg = -1, 
  2091. 	on_select = cellphone_cheat_cat_select, 
  2092. 	on_nav = cellphone_phonebook_nav, 
  2093. 	on_back = cellphone_menu_sub_exit, 
  2094. 	cleanup = cellphone_phonebook_cleanup, 
  2095. 	[0] = { contact_name = "CELL_CHEAT_CAT_PLAYERABILITY"}, 
  2096. 	[1] = { contact_name = "CELL_CHEAT_CAT_VEHICLES"}, 
  2097. 	[2] = { contact_name = "CELL_CHEAT_CAT_WEAPONS"}, 
  2098. 	[3] = { contact_name = "CELL_CHEAT_CAT_WEATHER"}, 
  2099. 	[4] = { contact_name = "CELL_CHEAT_CAT_WORLD"}, 
  2100. } 
  2101.  
  2102. Cellphone_menu_cheat_spec = { 
  2103. 	menu_type = "phonebook", 
  2104. 	header_string = "", 
  2105. 	dynamic_menu = true, 
  2106. 	book_type = 3, 
  2107. 	cur_idx = 0, 
  2108. 	num_items = 1,  
  2109. 	handles = {}, 
  2110. 	image_peg = -1, 
  2111. 	on_select = cellphone_cheat_spec_select, 
  2112. 	on_nav = cellphone_phonebook_nav, 
  2113. 	on_back = cellphone_cheat_spec_back, 
  2114. 	cleanup = cellphone_phonebook_cleanup, 
  2115. 	[0] = { contact_name = "cheat1"}, 
  2116. } 
  2117.  
  2118. Cellphone_menu_cheat_added = { 
  2119. 	menu_type = "cheat_added", 
  2120. 	header_string = "CELL_HEADER_CHEAT_ADDED", 
  2121. 	cur_idx = 0, 
  2122. 	num_items = 1,  
  2123. 	handles = {}, 
  2124. 	on_select = cellphone_menu_sub_exit, 
  2125. 	on_back = cellphone_menu_sub_exit, 
  2126. 	[0] = {dummy_data = -1} 
  2127. } 
  2128.  
  2129. Cellphone_menu_cheat_activate = { 
  2130. 	menu_type = "cheat_activated", 
  2131. 	header_string = "CELL_HEADER_CHEAT_ACTIVATED", 
  2132. 	cur_idx = 0,  
  2133. 	num_items = 1,  
  2134. 	handles = {}, 
  2135. 	on_select = cellphone_menu_sub_exit, 
  2136. 	on_back = cellphone_menu_sub_exit, 
  2137. 	[0] = {dummy_data = -1} 
  2138. } 
  2139.  
  2140. Cellphone_menu_main = { 
  2141. 	menu_type = "main", 
  2142. 	header_string = "", 
  2143. 	num_items = 4, 
  2144. 	cur_idx = 0, 
  2145. 	on_nav = cellphone_menu_main_item_nav, 
  2146. 	on_select = cellphone_menu_main_item_select, 
  2147. 	on_back = cellphone_menu_main_back, 
  2148. 	handles = {}, 
  2149. 	[0] = { label = "CELL_OPTION_HOMIES", sub_menu = Cellphone_menu_homies, bmp = "ui_menu_cell_homies", bmp_offset_x = 0, bmp_offset_y = 0, grp_h = 0 }, 
  2150. 	[1] = { label = "CELL_OPTION_DIAL", sub_menu = Cellphone_menu_dial, bmp = "ui_menu_cell_dial", bmp_offset_x = 44, bmp_offset_y = 0, grp_h = 0 }, 
  2151. 	[2] = { label = "CELL_OPTION_PHONEBOOK", sub_menu = Cellphone_menu_book, bmp = "ui_menu_cell_phonebook", bmp_offset_x = 78, bmp_offset_y = 0, grp_h = 0 }, 
  2152. 	[3] = { label = "CELL_OPTION_CHEATS", sub_menu = Cellphone_menu_cheat_cat, bmp = "ui_menu_cell_cheats", bmp_offset_x = 62, bmp_offset_y = 0, grp_h = 0 }, 
  2153. } 
  2154.  
  2155.  
  2156.