./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 STICK_IMG_PS3_X = 2 
  16. local STICK_IMG_PS3_Y = 2 
  17. local STICK_IMG_PS4_X = 2	-- HVS_JRP[PRINCE] 3/18/2014 
  18. local STICK_IMG_PS4_Y = 2	-- HVS_JRP[PRINCE] 3/18/2014 
  19.  
  20. local WEAPON_HIGHLIGHT_PREVIOUS_SELECTED 	= -1 
  21. local WEAPON_HIGHLIGHT_SELECT_NONE 			= -2 
  22.  
  23. local upgrade_slots = {} 
  24. --local Dpad_menu_is_enabled = true 
  25.  
  26. function vdo_weapon_radial_init() 
  27. 	SOUND_RADIAL_OPEN = game_audio_get_audio_id("SYS_WEP_MENU") 
  28. 	SOUND_RADIAL_SELECT = game_audio_get_audio_id("SYS_WEP_SCROLL") 
  29. 	SOUND_RADIAL_EQUIP_WEAPON = game_audio_get_audio_id("SYS_RADIAL_WEAPON_EQUIP") 
  30. 	SOUND_RADIAL_EQUIP_GRENADE = game_audio_get_audio_id("SYS_RADIAL_DRUG_EQUIP") 
  31. end 
  32.  
  33. function Vdo_weapon_radial:init() 
  34. 	--Member Variables 
  35. 	self.slots = {} 
  36. 	self.selected_weapon_slot = -1 
  37. 	self.selected_grenade_slot = -1 
  38. 	self.equipped_weapon_slot = -1 
  39. 	self.equipped_grenade_slot = -1 
  40. 	self.store_highlight = -1 
  41. 	self.slot_dpad_highlight_grp = -1 
  42. 	self.btn_hint = -1 
  43. 	self.store_mode_is_enabled = false 
  44. 	self.cache_is_enabled = false 
  45. 	self.last_selected_slot = -1 
  46. 	self.upgrades_grp = -1 
  47. 	self.upgrade_slots = {} 
  48. 	 
  49. 	--Initialize all slots 
  50. 	local slot 
  51. 	for i = 0, 11 do 
  52. 		slot = "slot_" .. i 
  53. 		self.slots[i] = Vdo_weapon_radial_slot:new(slot, self.handle, self.doc_handle) 
  54. 		self.slots[i].anchor_x, self.slots[i].anchor_y = self.slots[i]:get_anchor() 
  55. 	end 
  56. 	 
  57. 	-- Find objects to adjust for different platforms 
  58. 	local stick_grp_h = vint_object_find("control_stick", self.handle, self.doc_handle) 
  59. 	local stick_img_h = vint_object_find("base_stick_circle_img", self.handle, self.doc_handle) 
  60. 	local dpad_img_h = vint_object_find("dpad_img", self.handle, self.doc_handle) 
  61. 	local dots_grp_h = vint_object_find("dots_grp", self.handle, self.doc_handle) 
  62. 	local platform = game_get_platform() 
  63. 	 
  64. 	if game_is_active_input_gamepad() == false then 
  65. 	 
  66. 		--We're using keyboard and mouse, don't show stick and dpad 
  67. 		vint_set_property(stick_grp_h, "visible", false) 
  68. 		vint_set_property(dpad_img_h, "visible", false)		 
  69. 	elseif platform == "PS3" then 
  70. 	 
  71. 		--On PS3, hide the stick dots and change the dpad and stick image 
  72. 		vint_set_property(dots_grp_h, "visible", false) 
  73. 		vint_set_property(dpad_img_h, "image", "ui_ctrl_ps3_dpad_n")		 
  74. 		vint_set_property(dpad_img_h, "tint", 1, 1, 1)		 
  75. 		vint_set_property(dpad_img_h, "scale", 1.15, 1.15)		 
  76. 		 
  77. 		vint_set_property(stick_img_h, "image", "ui_hud_combo_thumb_ps3")				 
  78. 		vint_set_property(stick_img_h, "anchor", STICK_IMG_PS3_X, STICK_IMG_PS3_Y)				 
  79. 		vint_set_property(stick_img_h, "scale", 1, 1)				 
  80. 		vint_set_property(stick_grp_h, "scale", 1, 1)				 
  81. 	elseif platform == "PS4" then	-- HVS_JRP[PRINCE] 3/18/2014 
  82. 	 
  83. 		--On PS4, hide the stick dots and change the dpad and stick image 
  84. 		vint_set_property(dots_grp_h, "visible", false) 
  85. 		vint_set_property(dpad_img_h, "image", "ui_ctrl_ps4_dpad_n")		 
  86. 		vint_set_property(dpad_img_h, "tint", 1, 1, 1)		 
  87. 		vint_set_property(dpad_img_h, "scale", 1.15, 1.15)		 
  88. 		 
  89. 		vint_set_property(stick_img_h, "image", "ui_hud_combo_thumb_ps4")				 
  90. 		vint_set_property(stick_img_h, "anchor", STICK_IMG_PS4_X, STICK_IMG_PS4_Y)				 
  91. 		vint_set_property(stick_img_h, "scale", 1, 1)				 
  92. 		vint_set_property(stick_grp_h, "scale", 1, 1)	 
  93. 	elseif platform == "XBOX3" then	-- HVS_JRP[PRINCE] 3/18/2014 
  94. 	 
  95. 		--On XBox One, change the dpad image 
  96. 		vint_set_property(dpad_img_h, "image", "ui_ctrl_xbox3_dpad_n")		 
  97. 		vint_set_property(dpad_img_h, "tint", 1, 1, 1)		 
  98. 		vint_set_property(dpad_img_h, "scale", 1.15, 1.15)		 
  99. 			 
  100. 	end	 
  101. 	 
  102. 	--Clear out text fields on init... 
  103. 	local weapon_txt = Vdo_base_object:new("weapon_text", self.handle, self.doc_handle) 
  104. 	weapon_txt:set_text("") 
  105. 	 
  106. 	local dpad_txt = Vdo_base_object:new("dpad_text", self.handle, self.doc_handle) 
  107. 	dpad_txt:set_text("") 
  108. 	 
  109. 	--Hide weapon text grp until needed 
  110. 	self.weapon_text_grp_h = vint_object_find("weapon_text_grp", self.handle, self.doc_handle) 
  111. 	self.slot_highlight = Vdo_base_object:new("slot_highlight_grp", self.handle, self.doc_handle) 
  112. 	self.slot_dpad_highlight_grp = Vdo_base_object:new("slot_dpad_highlight_grp", self.handle, self.doc_handle) 
  113. 	self.btn_hint = Vdo_hint_button:new("btn_hint", self.handle, self.doc_handle) 
  114. 	self.arrow_bmp = Vdo_base_object:new("arrow", self.handle, self.doc_handle) 
  115. 	self.bg_grp_h = vint_object_find("bg_grp", self.handle, self.doc_handle) 
  116. 	 
  117. 	vint_set_property(self.weapon_text_grp_h, "visible", false) 
  118. 	self.btn_hint:set_visible(false) 
  119. 	 
  120. 	self.btn_hint:set_button(CTRL_MENU_BUTTON_A) 
  121. 	 
  122. 	self.stick_grp = Vdo_base_object:new("control_stick", self.handle, self.doc_handle) 
  123. 		 
  124. 	-- HVS_JPM handle the upgrade display 
  125. 	self.upgrades_grp = vint_object_find("weapon_upgrades_grp", self.handle, self.doc_handle) 
  126. 	vint_set_property(self.upgrades_grp, "visible", false) 
  127.  
  128. 	for i = 1, 5 do 
  129. 		self.upgrade_slots[i] = Vdo_weapon_pips:new("pips_0" .. i, self.handle, self.doc_handle) 
  130. 		self.upgrade_slots[i]:hide_upgrade_info() 
  131. 	end 
  132. 	--Find stick imgs to set to highlight color 
  133. 	self.stick_img_grp_h = vint_object_find("stick_img_grp", self.handle, self.doc_handle) 
  134.  
  135. 	-- PC: Hide dpad and control stick 
  136. 	local gamepad_in_use = game_is_active_input_gamepad() 
  137. 	self.stick_grp:set_visible(gamepad_in_use) 
  138. 	self.arrow_bmp:set_visible(gamepad_in_use) 
  139. 	 
  140. 	local weapon_highlight_anim_h = vint_object_find("weapon_highlight_anim", self.handle, self.doc_handle) 
  141. 	local dpad_highlight_anim_h = vint_object_find("dpad_highlight_anim", self.handle, self.doc_handle) 
  142. 	 
  143. 	lua_play_anim(weapon_highlight_anim_h) 
  144. 	lua_play_anim(dpad_highlight_anim_h) 
  145. end 
  146.  
  147. function Vdo_weapon_radial:cleanup() 
  148. 	-- Temp: bitmap doesn't line up with triangle edges 
  149. end 
  150.  
  151. function Vdo_weapon_radial:show(is_visible) 
  152. 	if is_visible == nil then 
  153. 		is_visible = false 
  154. 	end 
  155. 	 
  156. 	self:stick_arrow_reset() 
  157. 	 
  158. 	self:set_visible(is_visible) 
  159. 	 
  160. 	local dpad_menu_h = vint_object_find("dpad_menu", self.handle, self.doc_handle) 
  161. 	local dpad_text_grp_h = vint_object_find("dpad_text_grp", self.handle, self.doc_handle) 
  162. 	local radial_dpad_grp_h = vint_object_find("radial_dpad_grp", self.handle, self.doc_handle) 
  163. 	local weapon_text_pos_grp_h = vint_object_find("weapon_text_pos_grp", self.handle, self.doc_handle)	 
  164. 	local darken_scrim_img_h = vint_object_find("darken_scrim_img", self.handle, self.doc_handle) 
  165. 	local outer_circle_img_h = vint_object_find("outer_circle_img_1", self.handle, self.doc_handle) 
  166. 	local weapon_upgrades_group = vint_object_find("weapon_upgrades_grp", self.handle, self.doc_handle) 
  167. 	local WEAPON_RADIAL_NO_DPAD_OFFSET = 140 
  168. 	 
  169. 	if self.hide_dpad ~= false then 
  170. 		--hide dpad group 
  171. 		vint_set_property(dpad_menu_h, "visible", false) 
  172. 		vint_set_property(dpad_text_grp_h, "visible", false) 
  173. 		 
  174. 		--shift radial over 
  175. 		if self.store_mode_is_enabled == false then 
  176. 			vint_set_property(radial_dpad_grp_h, "anchor", WEAPON_RADIAL_NO_DPAD_OFFSET, 0) 
  177. 			vint_set_property(weapon_text_pos_grp_h, "anchor", WEAPON_RADIAL_NO_DPAD_OFFSET, 0) 
  178. 		end 
  179. 	else 
  180. 		--unhide dpad group 
  181. 		vint_set_property(dpad_menu_h, "visible", true) 
  182. 		vint_set_property(dpad_text_grp_h, "visible", true) 
  183. 		 
  184. 		--shift radial back 
  185. 		vint_set_property(radial_dpad_grp_h, "anchor", 0, 0) 
  186. 		vint_set_property(weapon_text_pos_grp_h, "anchor", 0, 0) 
  187. 		 
  188. 		-- Show only the available grenade slots.  Slot 8 is always on, so check 9 through 11. 
  189. 		for i = 9, 11 do 
  190. 			local weapon_level_obj = Vdo_base_object:new("slot_" .. i, self.handle, self.doc_handle) 
  191. 			if self.slots[i].level >= 1 then 
  192. 				--show slot 
  193. 				weapon_level_obj:set_visible(true) 
  194. 			else 
  195. 				--hide slot 
  196. 				weapon_level_obj:set_visible(false) 
  197. 			end 
  198. 		end 
  199. 	end 
  200. 	 
  201. 	if self.store_mode_is_enabled then 
  202. 		vint_set_property(darken_scrim_img_h, "visible", false) 
  203. 		vint_set_property(outer_circle_img_h, "visible", false) 
  204. 		vint_set_property(weapon_upgrades_group, "visible", false) 
  205. 		 
  206. 		local radial_gradient_img_h = vint_object_find("radial_gradient_img", self.handle, self.doc_handle) 
  207. 		vint_set_property(radial_gradient_img_h, "visible", false) 
  208. 	else 
  209. 		if game_get_platform() == "PC" then 
  210. 			local screen_size_x, screen_size_y = vint_get_screen_size() 
  211. 			element_set_actual_size(darken_scrim_img_h, screen_size_x*2, screen_size_y*2) 
  212. 			 
  213. 			local scanlines_grp_h = vint_object_find("scanlines_grp", self.handle, self.doc_handle) 
  214. 			if screen_size_x/screen_size_y >= 1.8 then 
  215. 				vint_set_property(scanlines_grp_h, "visible", false) 
  216. 			end 
  217. 		end 
  218. 	end 
  219. end 
  220.  
  221. --Updates position of stick on the radial menu 
  222. --stick_x:	-1 to 1 horizontal position of the stick on analog 
  223. --stick_y:	-1 to 1 vertical position of the stick on analog 
  224. function Vdo_weapon_radial:stick_update_position(stick_x, stick_y) 
  225. 	local x = stick_x * STICK_TRAVEL_DISTANCE 
  226. 	local y = -stick_y * STICK_TRAVEL_DISTANCE 
  227. 	local stick_grp = Vdo_base_object:new("stick_grp", self.handle, self.doc_handle) 
  228. 	stick_grp:set_anchor(x, y) 
  229. end 
  230.  
  231. --Updates the tag of the analog stick with the proper text (RS, LS, R, L) 
  232. function Vdo_weapon_radial:stick_update_tag() 
  233. 	local stick_txt = Vdo_base_object:new("stick_text", self.handle, self.doc_handle) 
  234. 	stick_txt:set_text(get_control_stick_text()) 
  235. end 
  236.  
  237. function Vdo_weapon_radial:stick_update_arrow(rotation_radians) 
  238. 	local new_radians = rotation_radians + (PI / 2) 
  239. 	self.arrow_bmp:set_rotation(-new_radians) 
  240. end 
  241.  
  242. --Reset arrow to currently highlighted weapon... 
  243. function Vdo_weapon_radial:stick_arrow_reset() 
  244. 	local new_radians = 0 
  245. 	local offset = PI  
  246. 	new_radians = (self.selected_weapon_slot/8) * PI2  + offset	 
  247. 	self.arrow_bmp:set_rotation(new_radians) 
  248. end 
  249.  
  250. --Highlights a slot on the weapon radial 
  251. function Vdo_weapon_radial:weapon_highlight(slot_num, skip_audio, force_update)	 
  252. 	local selector_grp 
  253. 	local weapon_txt 
  254. 	local selected_slot_old 
  255. 	local slot_old_obj  
  256. 	local slot_new_obj  
  257. 	local dpad_menu 
  258. 	local dpad_menu_x = 0 
  259. 	local dpad_menu_y = 0 
  260. 	local weapon_name_tag = "" 
  261. 	 
  262. 	-- slot_num == -1 can be passed in to just update previous slot 
  263. 	if slot_num == -1 then 
  264. 		slot_num = self.selected_weapon_slot 
  265. 	end 
  266. 	 
  267. 	if slot_num < 8 then		 
  268. 		weapon_txt = Vdo_base_object:new("weapon_text", self.handle, self.doc_handle) 
  269. 		selector_grp = Vdo_base_object:new("slot_weapon_select", self.handle, self.doc_handle) 
  270. 				 
  271. 		slot_old_obj = self.slots[self.selected_weapon_slot] 
  272. 		slot_new_obj = self.slots[slot_num] 
  273. 		 
  274. 		--Store slot variables 
  275. 		selected_slot_old = self.selected_weapon_slot 
  276. 		self.selected_weapon_slot = slot_num 
  277. 		 
  278. 		self:stick_arrow_reset() 
  279. 		 
  280. 		--Set text 
  281. 		if slot_new_obj.weapon_name_crc ~= 0 then 
  282. 			--no level appended... 
  283. 			local base_weapon_string = "{0:text_tag_crc}\n{1:text_tag_crc}" 
  284. 			local values = {[0] = slot_new_obj.weapon_class_crc, [1] = slot_new_obj.weapon_name_crc} 
  285. 			weapon_name_tag = vint_insert_values_in_string(base_weapon_string, values) 
  286. 		else 
  287. 			--weapon has no name (fist) 
  288. 			if slot_num == 0 then 
  289. 				weapon_name_tag = "HUD_UNARMED" 
  290. 			end 
  291. 		end 
  292.  
  293. 		vint_set_property(self.weapon_text_grp_h, "visible", true)					 
  294. 		if self.store_mode_is_enabled then 
  295. 			vint_set_property(self.upgrades_grp, "visible", false)	 
  296. 		else 
  297. 			-- HVS_JPM show the upgrade information for this weapon 
  298. 			if slot_num == 0 then 
  299. 				vint_set_property(self.upgrades_grp, "visible", false)	 
  300. 			elseif slot_new_obj.weapon_name_crc ~= 0 then 
  301. 				vint_set_property(self.upgrades_grp, "visible", true) 
  302. 				for i = 1, 5 do 
  303.  
  304. 					--Get upgrade data from code 
  305. 					--vint_dataresponder_request("ui_hud_weapon_upgrades_dr", "vdo_weapon_radial_set_upgrade_info", 0, slot_num, i ) 
  306. 					local upgrade_name_crc, current_level, max_level, attribute_id, is_ultimate, upgrade_idx, fully_upgraded = ui_hud_get_weapon_upgrade_info(slot_num, i) 
  307.  
  308. 					if upgrade_name_crc == 0 or upgrade_name_crc == nil then 
  309. 						self.upgrade_slots[upgrade_idx]:hide_upgrade_info() 
  310. 					else  
  311. 						self.upgrade_slots[upgrade_idx]:show_upgrade_info(upgrade_name_crc, max_level, current_level, is_ultimate, fully_upgraded) 
  312. 					end 
  313.  
  314. 				end	 
  315. 			end 
  316. 		end 
  317. 	else 
  318. 		 
  319. 		--If powers are hidden don't play audio. 
  320. 		if self.hide_dpad == true then 
  321. 			skip_audio = true 
  322. 		end 
  323. 	 
  324. 		--Powers 
  325. 		weapon_txt = Vdo_base_object:new("dpad_text", self.handle, self.doc_handle) 
  326. 		selector_grp = Vdo_base_object:new("slot_dpad_select_grp", self.handle, self.doc_handle) 
  327. 		dpad_menu = Vdo_base_object:new("dpad_menu", self.handle, self.doc_handle) 
  328. 		dpad_menu_x, dpad_menu_y = dpad_menu:get_anchor()		 
  329. 			 
  330. 		if self.slots[slot_num].level == 0 then 
  331. 			--grenade slot is not unlocked yet.  Return early 
  332. 			return 
  333. 		end 
  334.  
  335. 		slot_old_obj = self.slots[self.selected_grenade_slot] 
  336. 		slot_new_obj = self.slots[slot_num] 
  337. 		 
  338. 		--Set Text 
  339. 		self.element = self.slots[slot_num].element 
  340. 		local base_weapon_string = "{0:text_tag_crc}\n{1}" 
  341. 		local values = {[0] = slot_new_obj.weapon_name_crc, [1] = POWERS_ELEMENTS_ENUMS[self.element].short_label } 
  342. 		if slot_new_obj.weapon_name_crc ~= 0 then 
  343. 			weapon_name_tag = vint_insert_values_in_string(base_weapon_string, values) 
  344. 		else 
  345. 			weapon_name_tag = "" 
  346. 		end 
  347. 		 
  348. 		--Store slot variables 
  349. 		selected_slot_old = self.selected_grenade_slot 
  350. 		self.selected_grenade_slot = slot_num 
  351. 	end 
  352.  
  353. 	--[[ 
  354. 	--Update name and weapon level 
  355. 	local level = slot_new_obj.level + 1 
  356. 	if self.store_mode_is_enabled then 
  357. 		if slot_new_obj.weapon_name_crc ~= 0 then 
  358. 			--no level appended... 
  359. 			local base_weapon_string = "{0:text_tag_crc}" 
  360. 			local values = {[0] = slot_new_obj.weapon_name_crc} 
  361. 			weapon_name_tag = vint_insert_values_in_string(base_weapon_string, values) 
  362. 		else 
  363. 			--weapon has no name (fist) 
  364. 			weapon_name_tag = "" 
  365. 		end 
  366. 	else 
  367. 		--append level.. 
  368. 		local values = {[0] = slot_new_obj.weapon_name_crc, [1] = level } 
  369. 		weapon_name_tag = vint_insert_values_in_string("MENU_WEAPON_LEVEL", values) 
  370. 	end 
  371. 	]] 
  372. 	 
  373. 	--Stores handle their selected slots differently, only one item  
  374. 	--can be selected at a time... 
  375. 	if self.store_mode_is_enabled then 
  376. 		slot_old_obj = self.slots[self.last_selected_slot] 
  377. 		slot_new_obj = self.slots[slot_num] 
  378. 		selected_slot_old = self.last_selected_slot 
  379. 		self.last_selected_slot = slot_num 
  380. 	end 
  381. 	 
  382. 	--Now do the menu update... 
  383. 	 
  384. 	local skip_highlight = false 
  385. 	 
  386. 	-- If in store use different highlight scheme 
  387. 	if self.store_mode_is_enabled then		 
  388. 		--Hide weapon text 
  389. 		vint_set_property(self.weapon_text_grp_h, "visible", false)		 
  390. 			 
  391. 		--Show button hint in store 
  392. 		self.btn_hint:set_visible(game_is_active_input_gamepad()) 
  393. 		 
  394. 		--If in store and not selected slot then dim out	 
  395. 		for i=0, #self.slots do		 
  396. 			if i == slot_num then 
  397. 				-- This slot is highlighted 
  398. 				self.slots[i]:set_highlight(true) 
  399. 			end		 
  400. 		end 
  401. 	else 
  402. 		self:set_highlight_color(COLOR_SAINTS_PURPLE)				 
  403. 	end 
  404. 	 
  405.  
  406. 	--Reset previous slot  
  407. 	if selected_slot_old ~= -1 then 
  408. 		slot_old_obj:set_scale(1,1)		 
  409. 		slot_old_obj:set_highlight(false)	 
  410. 	end 
  411. 	 
  412. 	--Scale up slot object 
  413. 	slot_new_obj:set_scale(1.25,1.25)		 
  414. 	slot_new_obj:set_highlight(true) 
  415. 	 
  416. 	--Move the selector to the new slot 
  417. 	--Offset A button so it doesn't cover ammo meter 
  418. 	local BUTTON_HINT_OFFSET_X = -15 
  419. 	local BUTTON_HINT_OFFSET_Y = 44	 
  420. 	local selector_x, selector_y = slot_new_obj.anchor_x, slot_new_obj.anchor_y 
  421. 	 
  422. 	--get parent scale of radial to offset btn hint 
  423. 	local radial_dpad_grp_h = vint_object_find("radial_dpad_grp", self.handle, self.doc_handle) 
  424. 	local parent_scale_x, parent_scale_y = vint_get_property(radial_dpad_grp_h, "scale") 
  425. 	 
  426. 	selector_grp:set_anchor(selector_x, selector_y) 	 
  427. 	self.btn_hint:set_anchor(selector_x * parent_scale_x + BUTTON_HINT_OFFSET_X, selector_y * parent_scale_y + BUTTON_HINT_OFFSET_Y)  
  428. 	 
  429. 	--Set name of weapon... 
  430. 	weapon_txt:set_text(weapon_name_tag) 
  431. 	 
  432. 	--hide box if blank 
  433. 	local weapon_text_pos_grp_h = vint_object_find("weapon_text_pos_grp", self.handle, self.doc_handle) 
  434. 	local dpad_text_pos_grp_h = vint_object_find("dpad_text_pos_grp", self.handle, self.doc_handle) 
  435. 	 
  436. 	if weapon_name_tag == "" then 
  437. 		if slot_num < 8 then 
  438. 			vint_set_property(weapon_text_pos_grp_h, "alpha", .3)	 
  439. 		else 
  440. 			vint_set_property(dpad_text_pos_grp_h, "alpha", .3)	 
  441. 		end 
  442. 	else 
  443. 		if slot_num < 8 then 
  444. 			vint_set_property(weapon_text_pos_grp_h, "alpha", 1)	 
  445. 		else 
  446. 			vint_set_property(dpad_text_pos_grp_h, "alpha", 1)	 
  447. 		end 
  448. 	end 
  449. 	 
  450. 	--Update size of scrim behind weapon text... 
  451. 	local max_width, max_height = weapon_txt:get_actual_size() 
  452. 	local new_x = max(max_width/2 + 8, 87) 
  453. 	local new_width = max(max_width + 16, 174) 
  454. 	local corner_ne 
  455. 	local corner_se 
  456. 	local corner_nw 
  457. 	local corner_sw 
  458. 	local scrim 
  459. 	 
  460. 	if slot_num < 8 then	 
  461. 		corner_ne = vint_object_find("weapon_corner_ne_img") 
  462. 		corner_se = vint_object_find("weapon_corner_se_img") 
  463. 		corner_nw = vint_object_find("weapon_corner_nw_img") 
  464. 		corner_sw = vint_object_find("weapon_corner_sw_img") 
  465. 		scrim = vint_object_find("level_scrim_img") 
  466. 	else 
  467. 		corner_ne = vint_object_find("power_corner_ne_img") 
  468. 		corner_se = vint_object_find("power_corner_se_img") 
  469. 		corner_nw = vint_object_find("power_corner_nw_img") 
  470. 		corner_sw = vint_object_find("power_corner_sw_img") 
  471. 		scrim = vint_object_find("dpad_level_scrim_img") 
  472. 	end 
  473. 	 
  474. 	local corner_ne_x, corner_ne_y = vint_get_property(corner_ne, "anchor") 
  475. 	local corner_se_x, corner_se_y = vint_get_property(corner_se, "anchor") 
  476. 	local corner_nw_x, corner_nw_y = vint_get_property(corner_nw, "anchor") 
  477. 	local corner_sw_x, corner_sw_y = vint_get_property(corner_sw, "anchor") 
  478. 	local scrim_width, scrim_height = element_get_actual_size(scrim) 
  479. 	 
  480. 	vint_set_property(corner_ne, "anchor", new_x, corner_ne_y) 
  481. 	vint_set_property(corner_se, "anchor", new_x, corner_se_y) 
  482. 	vint_set_property(corner_nw, "anchor", -new_x, corner_nw_y) 
  483. 	vint_set_property(corner_sw, "anchor", -new_x, corner_sw_y) 
  484. 	element_set_actual_size(scrim, new_width ,scrim_height) 
  485. 	 
  486. 	--Play audio 
  487. 	if ( (skip_audio == false or skip_audio == nil) and ( selected_slot_old ~= slot_num ) ) then 
  488. 		game_UI_audio_play("UI_HUD_Select_Weapon") 
  489. 	end		 
  490. 	 
  491. 	-- PC: Hide dpad and control stick 
  492. 	local gamepad_in_use = game_is_active_input_gamepad() 
  493. 	vint_set_property(vint_object_find("dpad_img", self.handle, self.doc_handle), "visible", gamepad_in_use) 
  494. 	self.stick_grp:set_visible(gamepad_in_use) 
  495. 	self.arrow_bmp:set_visible(gamepad_in_use) 
  496. end 
  497.  
  498. function vdo_weapon_radial_set_upgrade_info( upgrade_name_crc, current_level, max_level, attribute_id, is_ultimate, upgrade_idx, fully_upgraded ) 
  499.  
  500. 	if upgrade_name_crc == 0 or upgrade_name_crc == nil then 
  501. 		self.upgrade_slots[upgrade_idx]:hide_upgrade_info() 
  502. 	else  
  503. 		self.upgrade_slots[upgrade_idx]:show_upgrade_info(upgrade_name_crc, max_level, current_level, is_ultimate, fully_upgraded) 
  504. 	end 
  505. end 
  506.  
  507. ---Equips currently selected slots in the radial menu for both weapons and grenades 
  508. function Vdo_weapon_radial:game_equip_selected_slots() 
  509. 	--Equip the Weapon First	 
  510. 	--have we actually selected something 
  511. 	if self.selected_weapon_slot ~= -1 then 
  512. 		--is it available? 
  513. 		if self.slots[self.selected_weapon_slot].availability == true then 
  514. 			--is the selected slot not the same as the equipped slot? 
  515. 			if self.selected_weapon_slot ~= self.equipped_weapon_slot then 
  516. 				local success = game_use_radial_menu_item(self.selected_weapon_slot) 
  517. 				if success then 
  518. 					self.equipped_weapon_slot = self.selected_weapon_slot  
  519. 				end 
  520. 			end 
  521. 		end 
  522. 	end 
  523. 	 
  524. 	--Set Power elements 
  525. 	for i=8, #self.slots do 
  526. 		game_set_grenade_ammo(i, self.slots[i].element) 
  527. 	end 
  528. 	 
  529. 	--Equip Grenade Now 
  530. 	if self.selected_grenade_slot ~= -1 then 
  531. 		--is it available? 
  532. 		if self.slots[self.selected_grenade_slot].availability == true then 
  533. 			-- is this slot unlocked? 
  534. 			if self.slots[self.selected_grenade_slot].level >= 1 then 
  535. 				--is the selected slot not the same as the equipped slot? 
  536. 				if self.selected_grenade_slot ~= self.equipped_grenade_slot then 
  537. 					local success = game_set_equipped_grenade(self.selected_grenade_slot) 
  538. 					if success then 
  539. 						self.equipped_grenade_slot = self.selected_grenade_slot  
  540. 					end 
  541. 				end 
  542. 			end 
  543. 		end 
  544. 	end 
  545. end 
  546.  
  547.  
  548. --Updates the weapon radial from the dataitem subscription 
  549. --[[ 
  550. 		Data Item Breakdown: 
  551. 		slot_num:			Slot number of item 
  552. 		availability:		Is the item available and can it be equipped? 
  553. 		weapon_name_crc:	crc for the item name (if nil then the item is empty 
  554. 		bmp_name:			bitmap representing the item 
  555. 		ammo_cur:			current ammo for the item (Weapons Only) 
  556. 		ammo_max:			max ammo for the item (Weapons Only) 
  557. 		dual_wield:			bool (Weapons Only) 
  558. 		ammo_infinite:		bool (Weapons Only) 
  559. 		is_current_wpn		Bool (Is Current Weapon)  
  560. 		level:				upgrade level of the weapon (0 is the base) 
  561. 		depleted:			bool (Weapons Only) 
  562. 		element				int  (powers only) 
  563. 		weapon_class_crc	crc for weapon class 
  564. 	]] 
  565. function Vdo_weapon_radial:slots_update(di_h)	 
  566. 	--Retreive Data from Dataitem 
  567. 	local slot_num, availability, weapon_name_crc, bmp_name, ammo_cur, ammo_max, dual_wield, ammo_infinite, is_current_wpn, level, depleted, element, weapon_class_crc, weapon_name, is_seven_deadly_sin = vint_dataitem_get(di_h)  
  568. 	local ammo_type = nil	-- removed from element list as it is no longer there 
  569. 	 
  570. 	--Get slot 
  571. 	local slot = self.slots[slot_num] 
  572. 	 
  573. 	--Force the fist icon if slot num is 0 and no bitmap name is provided 
  574. 	if slot_num == 0 and bmp_name == nil then 
  575. 		bmp_name = "ui_hud_inv_fist" 
  576. 	end 
  577. 	 
  578. 	--Update slot 
  579. 	slot:update(slot_num, availability, weapon_name_crc, bmp_name, ammo_cur, ammo_max, dual_wield, ammo_infinite, level, depleted, ammo_type, self.store_mode_is_enabled, element, weapon_class_crc, self.cache_is_enabled, weapon_name, is_seven_deadly_sin) 
  580. 	 
  581. 	--Set weapon currently equipped if it is the case 
  582. 	if slot_num < 8 then 
  583. 		if is_current_wpn == true then 
  584. 			self.equipped_weapon_slot = slot_num 
  585. 		end 
  586. 	else  
  587. 		if bmp_name ~= nil then 
  588. 			self.hide_dpad = false 
  589. 		end 
  590. 		 
  591. 		if is_current_wpn == true then 
  592. 			self.equipped_grenade_slot = slot_num			 
  593. 		end 
  594. 	end	 
  595. end 
  596.  
  597.  
  598. function Vdo_weapon_radial:loop_anim_cb(tween_h, event) 
  599. 	local anim_h = vint_object_parent(tween_h) 
  600. 	lua_play_anim(anim_h) 
  601. end 
  602.  
  603.  
  604. function Vdo_weapon_radial:play_show_anim() 
  605. 	local radial_show_anim_h = vint_object_find("radial_show_anim", self.handle, self.doc_handle) 
  606. 	lua_play_anim(radial_show_anim_h) 
  607. 	 
  608. 	local radial_bg_anim_h = vint_object_find("radial_bg_anim", self.handle, self.doc_handle) 
  609. 	lua_play_anim(radial_bg_anim_h) 
  610. 	 
  611. 	vint_set_glitch_preset("hub") 
  612. 	vint_spike_glitch( 100, 0 ) 
  613. end 
  614.  
  615.  
  616. function Vdo_weapon_radial:store_mode_enable(enable) 
  617. 	self.store_mode_is_enabled = enable 
  618. 	 
  619. 	vint_set_property(self.bg_grp_h, "visible", false) 
  620. end 
  621.  
  622.  
  623. function Vdo_weapon_radial:cache_mode_enable(enable) 
  624. 	self.cache_is_enabled = enable 
  625. end 
  626.  
  627.  
  628. function Vdo_weapon_radial:show_dpad_menu(is_visible) 
  629. 	local dpad_menu = Vdo_base_object:new("dpad_menu", self.handle, self.doc_handle) 
  630. 	dpad_menu:set_visible(is_visible) 
  631. 	 
  632. 	local dpad_text_grp_h = vint_object_find("dpad_text_grp", self.handle, self.doc_handle) 
  633. 	vint_set_property(dpad_text_grp_h, "visible", is_visible) 
  634. 	 
  635. 	self.hide_dpad = not is_visible 
  636. end 
  637.  
  638.  
  639. --SEH this needs to eventually determine if we last selected weapons or grenades, and return the right one 
  640. -- 
  641. function Vdo_weapon_radial:get_selected_slot() 
  642. 	return self.last_selected_slot 
  643. end 
  644.  
  645.  
  646. function Vdo_weapon_radial:set_highlight_color(color) 
  647. 	local platform = game_get_platform() 
  648. 	if (platform ~= "PS3") and (platform ~= "PS4") then	-- HVS_JRP[PRINCE] 3/18/2014 Added PS4 
  649. 		vint_set_property(self.stick_img_grp_h, "tint", color.R, color.G, color.B) 
  650. 	end 
  651. 	 
  652. 	self.arrow_bmp:set_property("tint", color.R, color.G, color.B) 
  653. 	self.slot_highlight:set_property("tint", color.R, color.G, color.B) 
  654. 	self.slot_dpad_highlight_grp:set_property("tint", color.R, color.G, color.B) 
  655. end 
  656.  
  657.  
  658. function Vdo_weapon_radial:slot_enable(slot_num) 
  659. 	self.slots[slot_num]:set_enabled(true) 
  660. end 
  661.  
  662.  
  663. function Vdo_weapon_radial:slot_disable(slot_num) 
  664. 	self.slots[slot_num]:set_enabled(false) 
  665. end 
  666.  
  667.  
  668. function Vdo_weapon_radial:slot_is_disabled(slot_num) 
  669. 	return not self.slots[slot_num].is_enabled	 
  670. end 
  671.  
  672. function Vdo_weapon_radial:slot_is_empty(slot_num) 
  673. 	if self.slots[slot_num].weapon_bmp_name ~= nil then 
  674. 		return false 
  675. 	else 
  676. 		return true 
  677. 	end 
  678. end 
  679.  
  680.  
  681.  
  682. function Vdo_weapon_radial:get_weapon_name(slot_num) 
  683. 	if self.store_mode_is_enabled then 
  684. 		return self.slots[slot_num].weapon_bmp_name 
  685. 	end 
  686. end 
  687.  
  688.  
  689. function Vdo_weapon_radial:slot_show_ammo(slot_num, is_visible) 
  690. 	self.slots[slot_num]:show_ammo(is_visible) 
  691. end 
  692.  
  693. function Vdo_weapon_radial:slot_has_infinite_ammo(slot_num) 
  694. 	return self.slots[slot_num]:has_infinite_ammo() 
  695. end 
  696.  
  697. function Vdo_weapon_radial:transparent_bg(transparent) 
  698. 	local gradient_h = vint_object_find("radial_gradient_img", self.handle, self.doc_handle) 
  699. 	local bg_grp = vint_object_find("bg_grp", self.handle, self.doc_handle) 
  700. 	local anim_h = vint_object_find("radial_show_anim", self.handle, self.doc_handle) 
  701. 	local twn_h = vint_object_find("darken_scrim_twn", anim_h) 
  702. 	 
  703. 	if transparent == true then 
  704. 		vint_set_property(gradient_h, "alpha", .3) 
  705. 		vint_set_property(bg_grp, "alpha", .8) 
  706. 		vint_set_property(twn_h, "end_value", .4) 
  707. 	else 
  708. 		vint_set_property(gradient_h, "alpha", 1) 
  709. 		vint_set_property(bg_grp, "alpha", 1) 
  710. 		vint_set_property(twn_h, "end_value", .8) 
  711. 	end 
  712. 	 
  713. end 
  714.  
  715. -- Adds mouse input subscriptions to the input tracker 
  716. -- 
  717. -- @param	func_prefix			Name of the screen that is currently using the hint bar 
  718. -- @param	input_tracker		The input tracker to hold the mouse inputs events 
  719. -- @param	priority				THe priority of the input event 
  720. function Vdo_weapon_radial:add_mouse_inputs(func_prefix, input_tracker, priority) 
  721. 	if func_prefix == nil then 
  722. 		return 
  723. 	end 
  724. 	 
  725. 	priority = priority or 50 
  726. 	 
  727. 	local mouse_click_function = func_prefix.."_mouse_click" 
  728. 	local mouse_move_function = func_prefix.."_mouse_move" 
  729.  
  730. 	for i = 1, #self.slots do 
  731. 		self.slots[i].slot_bmp_h = -1 
  732. 		-- Is this slot enabled 
  733. 		if self.slots[i].state == nil or self.slots[i].state == WEAPON_SLOT_STATE_ENABLED then 
  734. 			-- Is it visible 
  735. 			if self.hide_dpad or i < 8 then 
  736. 				-- Is it not disabled (for certain grendes) - This check probably not necessary 
  737. 				if i < 9 or self.slots[i].level >= 1 then 
  738. 					self.slots[i].slot_bmp_h = vint_object_find("base_bmp", self.slots[i].handle, self.doc_handle) 
  739. 					input_tracker:add_mouse_input("mouse_click", mouse_click_function, priority, self.slots[i].slot_bmp_h) 
  740. 					input_tracker:add_mouse_input("mouse_move", mouse_move_function, priority, self.slots[i].slot_bmp_h) 
  741. 				end 
  742. 			end 
  743. 		end 
  744. 	end 
  745. end 
  746.  
  747.  
  748. -- Mouse function: Return the slot matching the target_handle 
  749. function Vdo_weapon_radial:get_slot_index(target_handle) 
  750. 	for i = 1, #self.slots do 
  751. 		if target_handle == self.slots[i].slot_bmp_h then 
  752. 			return i 
  753. 		end 
  754. 	end 
  755. 	return 0 
  756. end 
  757.  
  758.  
  759. --SEH this needs to eventually determine if we last selected weapons or grenades, and return the right info. 
  760. -- This function finds the currently selected weapon, and return values related to ammo: 
  761. -- - current ammo count 
  762. -- - maximum ammo count 
  763. -- 
  764. -- function Vdo_weapon_radial:get_selected_ammo_info() 
  765. 	-- --Get slot 
  766. 	-- local slot = self.slots[self.selected_weapon_slot] 
  767. 	-- return slot.ammo_cur, slot.ammo_max 
  768. -- end 
  769.