./vdo_weapon_radial.lua

  1. -- Inherited from Vdo_base_object 
  2. Vdo_weapon_radial = Vdo_base_object:new_base() 
  3.  
  4. --Assign Audio IDs 
  5. local SOUND_RADIAL_OPEN  
  6. local SOUND_RADIAL_SELECT  
  7. local SOUND_RADIAL_EQUIP_WEAPON  
  8. local SOUND_RADIAL_EQUIP_GRENADE 
  9.  
  10. local STICK_TRAVEL_DISTANCE = 10 
  11.  
  12. local ANCHOR_DPAD_MENU_STORE_X = 238 
  13. local ANCHOR_DPAD_MENU_STORE_Y = 0 
  14.  
  15. local WEAPON_HIGHLIGHT_PREVIOUS_SELECTED 	= -1 
  16. local WEAPON_HIGHLIGHT_SELECT_NONE 			= -2 
  17.  
  18. local Dpad_menu_enabled = true 
  19.  
  20. function vdo_weapon_radial_init() 
  21. 	SOUND_RADIAL_OPEN = game_audio_get_audio_id("SYS_WEP_MENU") 
  22. 	SOUND_RADIAL_SELECT = game_audio_get_audio_id("SYS_WEP_SCROLL") 
  23. 	SOUND_RADIAL_EQUIP_WEAPON = game_audio_get_audio_id("SYS_RADIAL_WEAPON_EQUIP") 
  24. 	SOUND_RADIAL_EQUIP_GRENADE = game_audio_get_audio_id("SYS_RADIAL_DRUG_EQUIP") 
  25. end 
  26.  
  27. function Vdo_weapon_radial:init() 
  28. 	--Member Variables 
  29. 	self.slots = {} 
  30. 	self.selected_weapon_slot = -1 
  31. 	self.selected_grenade_slot = -1 
  32. 	self.equipped_weapon_slot = -1 
  33. 	self.equipped_grenade_slot = -1 
  34. 	self.purchase_grp = -1 
  35. 	self.store_highlight = -1 
  36. 	self.slot_grenade_highlight = -1 
  37. 	self.btn_hint = -1 
  38. 	self.store_mode_is_enabled = false 
  39. 	self.last_selected_slot = -1 
  40. 	 
  41. 	--Initialize all slots 
  42. 	local slot 
  43. 	for i = 0, 11 do 
  44. 		slot = "slot_" .. i 
  45. 		self.slots[i] = Vdo_weapon_radial_slot:new(slot, self.handle, self.doc_handle) 
  46. 	end 
  47. 	 
  48. 	--Change control stick depending on platform 
  49. 	local control_stick_bmp = Vdo_base_object:new("stick_bmp", self.handle, self.doc_handle) 
  50. 	control_stick_bmp:set_image(get_control_stick_thumb()) 
  51. 	 
  52. 	--Change base depending on platform 
  53. 	local stick_base_bmp = Vdo_base_object:new("base", self.handle, self.doc_handle) 
  54. 	stick_base_bmp:set_image(get_control_stick_base()) 
  55. 	 
  56. 	--Change d-pad depending on base 
  57. 	local dpad_bmp = Vdo_base_object:new("dpad", self.handle, self.doc_handle) 
  58. 	dpad_bmp:set_image(get_dpad_image()) 
  59. 	 
  60. 		--Clear out text fields on init... 
  61. 	local weapon_txt = Vdo_base_object:new("weapon_text", self.handle, self.doc_handle) 
  62. 	weapon_txt:set_text("") 
  63. 	weapon_txt = Vdo_base_object:new("grenade_text", self.handle, self.doc_handle) 
  64. 	weapon_txt:set_text("") 
  65. 	 
  66. 	--callbacks for looping highlight animations... 
  67. 	local weapon_radial_glow_twn = Vdo_tween_object:new("weapon_radial_glow_twn", self.handle, self.doc_handle) 
  68. 	local grenade_radial_glow_twn = Vdo_tween_object:new("grenade_radial_glow_twn", self.handle, self.doc_handle) 
  69. 	weapon_radial_glow_twn:set_property("end_event", "vint_anim_loop_callback") 
  70. 	grenade_radial_glow_twn:set_property("end_event", "vint_anim_loop_callback") 
  71. 	 
  72. 	self.purchase_grp = Vdo_base_object:new("purchase_grp", self.handle, self.doc_handle)		 
  73. 	self.store_highlight = Vdo_base_object:new("slot_highlight_store", self.handle, self.doc_handle) 
  74. 	self.slot_highlight = Vdo_base_object:new("slot_highlight", self.handle, self.doc_handle) 
  75. 	self.slot_grenade_highlight = Vdo_base_object:new("slot_grenade_highlight", self.handle, self.doc_handle) 
  76. 	self.btn_hint = Vdo_hint_button:new("btn_hint", self.handle, self.doc_handle) 
  77. 	self.arrow_bmp = Vdo_base_object:new("arrow", self.handle, self.doc_handle) 
  78. 	 
  79. 	self.purchase_grp:set_visible(false) 
  80. 	self.store_highlight:set_visible(false)		 
  81. 	self.slot_highlight:set_visible(false)		 
  82. 	self.slot_grenade_highlight:set_visible(false)		 
  83. 	self.btn_hint:set_visible(false) 
  84. 	 
  85. 	self.btn_hint:set_button(CTRL_MENU_BUTTON_A) 
  86. 	 
  87. 	self.stick_grp = Vdo_base_object:new("control_stick", self.handle, self.doc_handle) 
  88. 	self.dpad_bmp = Vdo_base_object:new("dpad", self.handle, self.doc_handle) 
  89.  
  90. 	-- PC: Hide dpad and control stick 
  91. 	local gamepad_in_use = game_is_active_input_gamepad() 
  92. 	self.stick_grp:set_visible(gamepad_in_use) 
  93. 	self.dpad_bmp:set_visible(gamepad_in_use) 
  94. 	self.arrow_bmp:set_visible(gamepad_in_use) 
  95. end 
  96.  
  97. function Vdo_weapon_radial:cleanup() 
  98. 	-- Temp: bitmap doesn't line up with triangle edges 
  99. end 
  100.  
  101. function Vdo_weapon_radial:show(is_visible) 
  102.  
  103. 	if is_visible == nil then 
  104. 		is_visible = false 
  105. 	end 
  106. 	 
  107. 	local weapon_radial_glow = Vdo_anim_object:new("weapon_radial_glow", self.handle, self.doc_handle) 
  108. 	local grenade_slot_glow = Vdo_anim_object:new("grenade_radial_glow", self.handle, self.doc_handle) 
  109. 	 
  110. 	self:stick_arrow_reset() 
  111. 	 
  112. 	self:set_visible(is_visible) 
  113.  
  114. 	-- Show only the available grenade slots.  Slot 8 is always on, so check 9 through 11. 
  115. 	for i = 9, 11 do 
  116. 		local weapon_level_obj = Vdo_base_object:new("slot_" .. i, self.handle, self.doc_handle) 
  117. 		if self.slots[i].level >= 1 then 
  118. 			--show slot 
  119. 			weapon_level_obj:set_visible(true) 
  120. 		else 
  121. 			--hide slot 
  122. 			weapon_level_obj:set_visible(false) 
  123. 		end 
  124. 	end 
  125. 	 
  126. 	-- Using a different highlight that doesn't animate for store mode	 
  127. 	if self.store_mode_is_enabled ~= true then 
  128. 		if is_visible == true then 
  129. 			--animate pulse 
  130. 			weapon_radial_glow:play() 
  131. 			grenade_slot_glow:play() 
  132. 		else 
  133. 			--stop animating pulse 
  134. 			weapon_radial_glow:stop() 
  135. 			grenade_slot_glow:stop() 
  136. 		end 
  137. 	else 
  138. 		-- JAM: Don't move the grenades up in 4:3, we don't have enough room 
  139. 		if not vint_is_std_res() then 
  140. 			local dpad_menu = Vdo_base_object:new("dpad_menu", self.handle, self.doc_handle) 
  141. 			dpad_menu:set_anchor(ANCHOR_DPAD_MENU_STORE_X,ANCHOR_DPAD_MENU_STORE_Y) 
  142. 		end 
  143. 		-- SEH: we want to stay on the last slot selected when purchasing/upgrading, so don't reset here in stores. 
  144. 		--intialize to first slot 
  145. 		--self:weapon_highlight(1, true) 
  146. 	end	 
  147. end 
  148.  
  149. --Updates position of stick on the radial menu 
  150. --stick_x:	-1 to 1 horizontal position of the stick on analog 
  151. --stick_y:	-1 to 1 vertical position of the stick on analog 
  152. function Vdo_weapon_radial:stick_update_position(stick_x, stick_y) 
  153. 	local x = stick_x * STICK_TRAVEL_DISTANCE 
  154. 	local y = -stick_y * STICK_TRAVEL_DISTANCE 
  155. 	local stick_grp = Vdo_base_object:new("stick_grp", self.handle, self.doc_handle) 
  156. 	stick_grp:set_anchor(x, y) 
  157. end 
  158.  
  159. --Updates the tag of the analog stick with the proper text (RS, LS, R, L) 
  160. function Vdo_weapon_radial:stick_update_tag() 
  161. 	local stick_txt = Vdo_base_object:new("stick_text", self.handle, self.doc_handle) 
  162. 	stick_txt:set_text(get_control_stick_text()) 
  163. end 
  164.  
  165. function Vdo_weapon_radial:stick_update_arrow(rotation_radians) 
  166. 	local new_radians = rotation_radians + (PI / 2) 
  167. 	self.arrow_bmp:set_rotation(-new_radians) 
  168. end 
  169.  
  170. --Reset arrow to currently highlighted weapon... 
  171. function Vdo_weapon_radial:stick_arrow_reset() 
  172. 	local new_radians = 0 
  173. 	local offset = PI  
  174. 	new_radians = (self.selected_weapon_slot/8) * PI2  + offset	 
  175. 	self.arrow_bmp:set_rotation(new_radians) 
  176. end 
  177.  
  178. --Highlights a slot on the weapon radial 
  179. function Vdo_weapon_radial:weapon_highlight(slot_num, skip_audio, force_update) 
  180. 	 
  181. 	local selector_grp 
  182. 	local weapon_txt 
  183. 	local selected_slot_old 
  184. 	local slot_old_obj  
  185. 	local slot_new_obj  
  186. 	local dpad_menu 
  187. 	local dpad_menu_x = 0 
  188. 	local dpad_menu_y = 0 
  189. 	local weapon_name_tag = "" 
  190.  
  191. 	 
  192. 	-- slot_num == -1 can be passed in to just update previous slot 
  193. 	if slot_num == -1 then 
  194. 		slot_num = self.selected_weapon_slot 
  195. 	end 
  196. 	 
  197. 	--Change text for the weapon radial 
  198. 	local slot_ammo = Vdo_base_object:new("slot_ammo", self.handle, self.doc_handle) 
  199. 	local img_ammo = Vdo_base_object:new("img_ammo", self.handle, self.doc_handle)	 
  200. 	 
  201. 	--Check if we are updating the radial or grenade if not in the store 
  202. 	 
  203. 	--and self.store_mode_is_enabled == false  
  204. 	 
  205. 	if slot_num < 8 then	 
  206. 	 
  207. 		weapon_txt = Vdo_base_object:new("weapon_text", self.handle, self.doc_handle) 
  208. 		selector_grp = Vdo_base_object:new("slot_weapon_select", self.handle, self.doc_handle) 
  209. 				 
  210. 		slot_old_obj = self.slots[self.selected_weapon_slot] 
  211. 		slot_new_obj = self.slots[slot_num] 
  212. 		 
  213. 		--Store slot variables 
  214. 		selected_slot_old = self.selected_weapon_slot 
  215. 		self.selected_weapon_slot = slot_num 
  216. 		 
  217. 		--Update name and weapon level 
  218. 		local level = slot_new_obj.level + 1 
  219. 		if self.store_mode_is_enabled == true or level <= 1 then 
  220. 			if slot_new_obj.weapon_name_crc ~= 0 then 
  221. 				--no level appended... 
  222. 				local base_weapon_string = "{0:text_tag_crc}" 
  223. 				local values = {[0] = slot_new_obj.weapon_name_crc} 
  224. 				weapon_name_tag = vint_insert_values_in_string(base_weapon_string, values) 
  225. 			else 
  226. 				--weapon has no name (fist) 
  227. 				weapon_name_tag = "" 
  228. 			end 
  229. 		else 
  230. 			--no level appended... 
  231. 			local values = {[0] = slot_new_obj.weapon_name_crc, [1] = level } 
  232. 			weapon_name_tag = vint_insert_values_in_string("MENU_WEAPON_LEVEL", values) 
  233. 		end 
  234.  
  235. 		self:stick_arrow_reset() 
  236. 	else 
  237. 		--Grenades 
  238. 		weapon_txt = Vdo_base_object:new("grenade_text", self.handle, self.doc_handle) 
  239. 		selector_grp = Vdo_base_object:new("slot_grenade_select", self.handle, self.doc_handle) 
  240. 		dpad_menu = Vdo_base_object:new("dpad_menu", self.handle, self.doc_handle) 
  241. 		dpad_menu_x, dpad_menu_y = dpad_menu:get_anchor()		 
  242. 			 
  243. 		if self.slots[slot_num].level == 0 then 
  244. 			--grenade slot is not unlocked yet.  Return early 
  245. 			return 
  246. 		end 
  247.  
  248. 		slot_old_obj = self.slots[self.selected_grenade_slot] 
  249. 		slot_new_obj = self.slots[slot_num] 
  250. 		 
  251. 		--Update name... (no level for grenades) 
  252. 		if slot_new_obj.weapon_name_crc ~= 0 then 
  253. 			local base_weapon_string = "{0:text_tag_crc}" 
  254. 			local values = {[0] = slot_new_obj.weapon_name_crc} 
  255. 			weapon_name_tag = vint_insert_values_in_string(base_weapon_string, values) 
  256. 		else 
  257. 			--weapon has no name (empty) 
  258. 			weapon_name_tag = "" 
  259. 		end 
  260. 		 
  261. 		--Store slot variables 
  262. 		selected_slot_old = self.selected_grenade_slot 
  263. 		self.selected_grenade_slot = slot_num 
  264. 	end 
  265.  
  266. 	--Stores handle their selected slots differently, only one item  
  267. 	--can be selected at a time... 
  268. 	if self.store_mode_is_enabled then 
  269. 		slot_old_obj = self.slots[self.last_selected_slot] 
  270. 		slot_new_obj = self.slots[slot_num] 
  271. 		selected_slot_old = self.last_selected_slot 
  272. 		self.last_selected_slot = slot_num 
  273. 	end 
  274. 	 
  275. 	--Now do the menu update... 
  276. 	 
  277. 	local skip_highlight = false 
  278. 	 
  279. 	-- If in store use different highlight scheme 
  280. 	if self.store_mode_is_enabled then			 
  281. 	 
  282. 	 
  283. 		--Hide standard weapon select highlights 
  284. 		self.slot_highlight:set_visible(false) 
  285. 		self.slot_grenade_highlight:set_visible(false) 
  286. 		weapon_txt:set_visible(false) 
  287. 	 
  288. 		--Reset parent of highlight handle and show the highlight 
  289. 		vint_object_set_parent(self.store_highlight.handle, selector_grp.handle) 
  290. 		self.store_highlight:set_visible(true) 
  291. 		 
  292. 		--Show button hint in store 
  293. 		self.btn_hint:set_visible(game_is_active_input_gamepad()) 
  294. 		 
  295. 		--If in store and not selected slot then dim out	 
  296. 		for i=0, #self.slots do		 
  297. 			if i == slot_num and self.slots[slot_num].state ~= WEAPON_SLOT_STATE_DISABLED then 
  298. 				-- This slot is highlighted 
  299. 				self.slots[i]:set_state(WEAPON_SLOT_STATE_HIGHLIGHTED) 
  300. 			elseif self.slots[i].state == WEAPON_SLOT_STATE_DISABLED then 
  301. 				self.slots[i]:set_state(WEAPON_SLOT_STATE_DISABLED) 
  302. 				if i == slot_num then  
  303. 					skip_highlight = true 
  304. 				end 
  305. 			else 
  306. 				self.slots[i]:set_state(WEAPON_SLOT_STATE_ENABLED) 
  307. 			end		 
  308. 		end 
  309. 	else 
  310. 		self:set_highlight_color(COLOR_SAINTS_PURPLE) 
  311. 		self.slot_highlight:set_visible(true)		 
  312. 		self.slot_grenade_highlight:set_visible(true)	 
  313. 	end 
  314. 	 
  315. 	--Check if we are trying to select the same weapon and exit early if so... 
  316. 	if slot_num == selected_slot_old and force_update ~= true then		 
  317. 		return 
  318. 	end 
  319. 	 
  320. 	--Reset previous slot  
  321. 	if selected_slot_old ~= -1 then 
  322. 		slot_old_obj:set_scale(1,1) 
  323. 	end 
  324. 	 
  325. 	if skip_highlight == false then 
  326. 		--Scale up slot object 
  327. 		slot_new_obj:set_scale(1.25,1.25)		 
  328. 		  
  329. 		--Move the selector to the new slot 
  330. 		--Offset A button so it doesn't cover ammo meter 
  331. 		local BUTTON_HINT_OFFSET_X = -15 
  332. 		local BUTTON_HINT_OFFSET_Y = 29	 
  333. 		local selector_x, selector_y = slot_new_obj:get_anchor() 
  334. 		 
  335. 		selector_grp:set_anchor(selector_x, selector_y) 	 
  336. 		self.btn_hint:set_anchor(selector_x + BUTTON_HINT_OFFSET_X + dpad_menu_x, selector_y + BUTTON_HINT_OFFSET_Y + dpad_menu_y) 
  337. 				 
  338. 		weapon_txt:set_text(weapon_name_tag) 
  339. 		 
  340. 		--Hide text if weapon doesn't have ammo 
  341. 		if slot_new_obj.ammo_cur == -1 then 
  342. 			slot_ammo:set_visible(false) 
  343. 			img_ammo:set_visible(false) 
  344. 		else 
  345. 			if self.store_mode_is_enabled then 
  346. 				slot_ammo:set_text(slot_new_obj.ammo_cur.."/"..slot_new_obj.ammo_max)	 
  347. 				img_ammo:set_image(slot_new_obj.ammo_type) 
  348. 				slot_ammo:set_visible(true) 
  349. 				img_ammo:set_visible(true) 
  350. 			end 
  351. 		end 
  352. 		 
  353. 		--Center ammo text 
  354. 		local slot_ammo_width, slot_ammo_height = element_get_actual_size(slot_ammo.handle) 
  355. 		local weapon_txt_x, weapon_txt_y = weapon_txt:get_anchor() 
  356. 		local AMMO_IMAGE_OFFSET = 12 
  357. 		self.purchase_grp:set_anchor(weapon_txt_x + AMMO_IMAGE_OFFSET, weapon_txt_y + 20) 
  358. 		img_ammo:set_anchor(slot_ammo_width * -0.5 - AMMO_IMAGE_OFFSET, 0)  
  359. 	end 
  360.  
  361. 	 
  362. 	--Play audio 
  363. 	if skip_audio == false or skip_audio == nil then 
  364. 		game_UI_audio_play("UI_HUD_Select_Weapon") 
  365. 	end		 
  366. 	 
  367. 	-- PC: Hide dpad and control stick 
  368. 	local gamepad_in_use = game_is_active_input_gamepad() 
  369. 	self.stick_grp:set_visible(gamepad_in_use) 
  370. 	self.dpad_bmp:set_visible(gamepad_in_use) 
  371. 	self.arrow_bmp:set_visible(gamepad_in_use) 
  372. end 
  373.  
  374.  
  375. function Vdo_weapon_radial:store_highlight(slot_num, skip_audio, force_update) 
  376.  
  377. end 
  378.  
  379. ---Equips currently selected slots in the radial menu for both weapons and grenades 
  380. function Vdo_weapon_radial:game_equip_selected_slots() 
  381. 	--Equip the Weapon First 
  382. 	 
  383. 	--have we actually selected something 
  384. 	if self.selected_weapon_slot ~= -1 then 
  385. 		--is it available? 
  386. 		if self.slots[self.selected_weapon_slot].availability == true then 
  387. 			--is the selected slot not the same as the equipped slot? 
  388. 			if self.selected_weapon_slot ~= self.equipped_weapon_slot then 
  389. 				local success = game_use_radial_menu_item(self.selected_weapon_slot) 
  390. 				if success then 
  391. 					self.equipped_weapon_slot = self.selected_weapon_slot  
  392. 				end 
  393. 			end 
  394. 		end 
  395. 	end 
  396. 	 
  397. 	--Equip Grenade Now 
  398. 	if self.selected_grenade_slot ~= -1 then 
  399. 		--is it available? 
  400. 		if self.slots[self.selected_grenade_slot].availability == true then 
  401. 			-- is this slot unlocked? 
  402. 			if self.slots[self.selected_grenade_slot].level >= 1 then 
  403. 				--is the selected slot not the same as the equipped slot? 
  404. 				if self.selected_grenade_slot ~= self.equipped_grenade_slot then 
  405. 					local success = game_set_equipped_grenade(self.selected_grenade_slot) 
  406. 					if success then 
  407. 						self.equipped_grenade_slot = self.selected_grenade_slot  
  408. 					end 
  409. 				end 
  410. 			end 
  411. 		end 
  412. 	end 
  413. end 
  414.  
  415.  
  416.  
  417. --Updates the weapon radial from the dataitem subscription 
  418. --[[ 
  419. 		Data Item Breakdown: 
  420. 		slot_num:			Slot number of item 
  421. 		availability:		Is the item available and can it be equipped? 
  422. 		weapon_name_crc:	crc for the item name (if nil then the item is empty 
  423. 		bmp_name:			bitmap representing the item 
  424. 		ammo_cur:			current ammo for the item (Weapons Only) 
  425. 		ammo_max:			max ammo for the item (Weapons Only) 
  426. 		dual_wield:			bool (Weapons Only) 
  427. 		is_current_wpn		Bool(	Is Current Weapon )  
  428. 		ammo_infinite:		bool (Weapons Only) 
  429. 		level:				upgrade level of the weapon (0 is the base) 
  430. 	]] 
  431. function Vdo_weapon_radial:slots_update(di_h) 
  432. 	 
  433. 	--Retreive Data from Dataitem 
  434. 	local slot_num, availability, weapon_name_crc, bmp_name, ammo_cur, ammo_max, dual_wield, ammo_infinite, is_current_wpn, level, ammo_type  = vint_dataitem_get(di_h)  
  435. 	 
  436. 	--Get slot 
  437. 	local slot = self.slots[slot_num] 
  438. 	 
  439. 	--Force the fist icon if slot num is 0 and no bitmap name is provided 
  440. 	if slot_num == 0 and bmp_name == nil then 
  441. 		bmp_name = "ui_hud_inv_fist" 
  442. 	end 
  443. 	 
  444. 	--Update slot 
  445. 	slot:update(slot_num, availability, weapon_name_crc, bmp_name, ammo_cur, ammo_max, dual_wield, ammo_infinite, level, ammo_type, self.store_mode_is_enabled) 
  446. 	 
  447. 	--Set weapon currently equipped if it is the case 
  448. 	if slot_num < 8 then 
  449. 		if is_current_wpn == true then 
  450. 			self.equipped_weapon_slot = slot_num 
  451. 		end 
  452. 	else  
  453. 		if is_current_wpn == true then 
  454. 			self.equipped_grenade_slot = slot_num 
  455. 		end 
  456. 	end 
  457. end 
  458.  
  459. function Vdo_weapon_radial:loop_anim_cb(tween_h, event) 
  460. 	local anim_h = vint_object_parent(tween_h) 
  461. 	lua_play_anim(anim_h) 
  462. end 
  463.  
  464. function Vdo_weapon_radial:store_mode_enable(enable) 
  465. 	self.store_mode_is_enabled = enable 
  466. 	 
  467. 	--Hide highlighted weapon text 
  468. 	local grenade_text = vint_object_find("grenade_text", self.handle, self.doc_handle) 
  469. 	local purchase_grp = vint_object_find("grenade_text", self.handle, self.doc_handle) 
  470. 	local weapon_level_grp = vint_object_find("grenade_text", self.handle, self.doc_handle) 
  471. 	local weapon_text = vint_object_find("grenade_text", self.handle, self.doc_handle) 
  472. 	 
  473. 	vint_set_property(grenade_text, "visible", false) 
  474. 	vint_set_property(purchase_grp, "visible", false) 
  475. 	vint_set_property(weapon_level_grp, "visible", false) 
  476. 	vint_set_property(weapon_text, "visible", false)	 
  477. end 
  478.  
  479. function Vdo_weapon_radial:show_dpad_menu(is_visible) 
  480. 	local dpad_menu = Vdo_base_object:new("dpad_menu", self.handle, self.doc_handle) 
  481. 	dpad_menu:set_visible(is_visible) 
  482. 	 
  483. 	Dpad_menu_enabled = is_visible 
  484. end 
  485.  
  486. --SEH this needs to eventually determine if we last selected weapons or grenades, and return the right one 
  487. -- 
  488. function Vdo_weapon_radial:get_selected_slot() 
  489. 	return self.last_selected_slot 
  490. end 
  491.  
  492. function Vdo_weapon_radial:set_highlight_color(color) 
  493. 	self.arrow_bmp:set_property("tint", color.R, color.G, color.B) 
  494. 	self.store_highlight:set_property("tint", color.R, color.G, color.B)	 
  495. 	self.slot_highlight:set_property("tint", color.R, color.G, color.B) 
  496. 	self.slot_grenade_highlight:set_property("tint", color.R, color.G, color.B) 
  497. end 
  498.  
  499. function Vdo_weapon_radial:slot_disable(slot_num) 
  500. 	if self.store_mode_is_enabled then 
  501. 		self.slots[slot_num].state = WEAPON_SLOT_STATE_DISABLED 
  502. 	end 
  503. end 
  504.  
  505. function Vdo_weapon_radial:slot_enable(slot_num) 
  506. 	if self.store_mode_is_enabled then 
  507. 		self.slots[slot_num].state = WEAPON_SLOT_STATE_ENABLED 
  508. 	end 
  509. end 
  510.  
  511. function Vdo_weapon_radial:slot_is_disabled(slot_num) 
  512. 	if self.store_mode_is_enabled then 
  513. 		if self.slots[slot_num].state  == WEAPON_SLOT_STATE_DISABLED then 
  514. 			return true 
  515. 		else 
  516. 			return false 
  517. 		end 
  518. 	else 
  519. 		return false 
  520. 	end 
  521. end 
  522.  
  523. -- Adds mouse input subscriptions to the input tracker 
  524. -- 
  525. -- @param	func_prefix			Name of the screen that is currently using the hint bar 
  526. -- @param	input_tracker		The input tracker to hold the mouse inputs events 
  527. -- @param	priority				THe priority of the input event 
  528. function Vdo_weapon_radial:add_mouse_inputs(func_prefix, input_tracker, priority) 
  529. 	if func_prefix == nil then 
  530. 		return 
  531. 	end 
  532. 	 
  533. 	priority = priority or 50 
  534. 	 
  535. 	local mouse_click_function = func_prefix.."_mouse_click" 
  536. 	local mouse_move_function = func_prefix.."_mouse_move" 
  537.  
  538. 	for i = 1, #self.slots do 
  539. 		self.slots[i].slot_bmp_h = -1 
  540. 		-- Is this slot enabled 
  541. 		if self.slots[i].state == nil or self.slots[i].state == WEAPON_SLOT_STATE_ENABLED then 
  542. 			-- Is it visible 
  543. 			if Dpad_menu_enabled or i < 8 then 
  544. 				-- Is it not disabled (for certain grendes) - This check probably not necessary 
  545. 				if i < 9 or self.slots[i].level >= 1 then 
  546. 					self.slots[i].slot_bmp_h = vint_object_find("base_bmp", self.slots[i].handle, self.doc_handle) 
  547. 					input_tracker:add_mouse_input("mouse_click", mouse_click_function, priority, self.slots[i].slot_bmp_h) 
  548. 					input_tracker:add_mouse_input("mouse_move", mouse_move_function, priority, self.slots[i].slot_bmp_h) 
  549. 				end 
  550. 			end 
  551. 		end 
  552. 	end 
  553. end 
  554.  
  555. -- Mouse function: Return the slot matching the target_handle 
  556. function Vdo_weapon_radial:get_slot_index(target_handle) 
  557. 	for i = 1, #self.slots do 
  558. 		if target_handle == self.slots[i].slot_bmp_h then 
  559. 			return i 
  560. 		end 
  561. 	end 
  562. 	return 0 
  563. end 
  564.  
  565. --SEH this needs to eventually determine if we last selected weapons or grenades, and return the right info. 
  566. -- This function finds the currently selected weapon, and return values related to ammo: 
  567. -- - current ammo count 
  568. -- - maximum ammo count 
  569. -- 
  570. -- function Vdo_weapon_radial:get_selected_ammo_info() 
  571. 	-- --Get slot 
  572. 	-- local slot = self.slots[self.selected_weapon_slot] 
  573. 	-- return slot.ammo_cur, slot.ammo_max 
  574. -- end 
  575.