-- Inherited from Vdo_base_object
Vdo_weapon_radial_slot = Vdo_base_object:new_base()
local Weapon_store_images = {
[1] = "ui_hud_inv_gen_melee",
[2] = "ui_hud_inv_gen_pistol",
[3] = "ui_hud_inv_gen_smg",
[4] = "ui_hud_inv_gen_shotgun",
[5] = "ui_hud_inv_gen_rifle",
[6] = "ui_hud_inv_gen_explosive",
[7] = "ui_hud_inv_gen_spc",
[8] = "ui_hud_inv_gen_grenade",
[9] = "ui_hud_inv_gen_molotov",
[10] = "ui_hud_inv_gen_flash",
[11] = "ui_hud_inv_gen_electric",
[12] = "ui_hud_inv_gen_melee",
}
--Local Constants
local AMMO_ANGLE_FULL = PI2 * -1
local AMMO_ANGLE_EMPTY = -4.7
local Vdo_weapon_radial_slot_dual_1_x = 0
local Vdo_weapon_radial_slot_dual_1_y = 0
local Vdo_weapon_radial_slot_dual_2_x = 0
local Vdo_weapon_radial_slot_dual_2_y = 0
function vdo_weapon_radial_slot_init()
local dual_1_h = vint_object_find("dual_inv_1_bmp")
local dual_2_h = vint_object_find("dual_inv_2_bmp")
Vdo_weapon_radial_slot_dual_1_x, Vdo_weapon_radial_slot_dual_1_y = vint_get_property(dual_1_h, "anchor")
Vdo_weapon_radial_slot_dual_2_x, Vdo_weapon_radial_slot_dual_2_y = vint_get_property(dual_2_h, "anchor")
end
function Vdo_weapon_radial_slot:init()
--Member Variables
self.slot_num = -1 --not used, just for debugging
self.weapon_name_crc = - 1 --crc for name of item
self.weapon_bmp = nil --Weapon Bitmap, if set to nil the no weapon
self.ammo_cur = -1 --Current ammount of ammo for clip
self.ammo_max = -1 --Maximum ammount of ammo for clip
self.ammo_infinite = -1 --Do we have infinite ammo?
self.dual_wield = -1 --Is weapon Dual wield?
self.weapon_bmp_name = -1 --Bitmap name for weapon
self.level = -1 --What is the current weapon level
self.availability = -1 --Is the weapon available
self.ammo_type = -1 --Bitmap for ammo type
self.is_outline = false --Is icon a placeholder outline?
self.is_highlighted = false --Is the slot highlighted or not?
self.element = -1 --Enum for the equipped element
self.weapon_class_crc = -1 --crc for class of item
self.weapon_name = -1 -- the weapon name in english
end
function Vdo_weapon_radial_slot:cleanup()
end
function Vdo_weapon_radial_slot:update(slot_num, availability, weapon_name_crc, weapon_bmp_name, ammo_cur, ammo_max, dual_wield, ammo_infinite, level, depleted, ammo_type, store_mode_is_enabled, element, weapon_class_crc, cache_is_enabled, weapon_name, is_seven_deadly_sin)
--Find bitmap references to update
local ammo_bar_fill_bmp = Vdo_base_object:new("ammo_circle", self.handle, self.doc_handle)
local ammo_bar_bg_bmp = Vdo_base_object:new("ammo_bg", self.handle, self.doc_handle)
local infinity_bmp = Vdo_base_object:new("infinity_bmp", self.handle, self.doc_handle)
--Find objects to change weapon bitmaps
local dual_inv_1_bmp = Vdo_base_object:new("dual_inv_1_bmp", self.handle, self.doc_handle)
local dual_inv_2_bmp = Vdo_base_object:new("dual_inv_2_bmp", self.handle, self.doc_handle)
local element_bmp_h = vint_object_find("element_bmp", self.handle, self.doc_handle)
--Tint ammo bar red if recharging
--local depleted = true
if depleted == true then
ammo_bar_fill_bmp:set_color(220/255, 37/255, 0/255)
dual_inv_1_bmp:set_alpha(.5)
dual_inv_2_bmp:set_alpha(.5)
else
ammo_bar_fill_bmp:set_color(220/255, 220/255, 220/255)
dual_inv_1_bmp:set_alpha(1)
dual_inv_2_bmp:set_alpha(1)
end
--Ammo Update
if ammo_cur ~= self.ammo_cur or ammo_max ~= self.ammo_max or ammo_infinite ~= self.ammo_infinite then
if ammo_max == 0 then
--No ammo clip, hide ammo bar and infinity symbol
ammo_bar_fill_bmp:set_visible(false)
ammo_bar_bg_bmp:set_visible(false)
infinity_bmp:set_visible(false)
self.ammo_infinite = -1
else
--Ammo Bar Fill
local ammo_percent = ammo_cur/ammo_max
if ammo_percent > 1 then
ammo_percent = 1
end
local angle = AMMO_ANGLE_EMPTY + (AMMO_ANGLE_FULL - AMMO_ANGLE_EMPTY) * ammo_percent
ammo_bar_fill_bmp:set_property("start_angle", angle)
--Do we show Infinity Symbol or Ammo bar?
if ammo_infinite ~= self.ammo_infinite then
if ammo_infinite == true then
ammo_bar_fill_bmp:set_visible(false)
ammo_bar_bg_bmp:set_visible(false)
infinity_bmp:set_visible(true)
else
ammo_bar_fill_bmp:set_visible(true)
ammo_bar_bg_bmp:set_visible(true)
infinity_bmp:set_visible(false)
end
self.ammo_infinite = ammo_infinite
end
self.ammo_cur = ammo_cur
self.ammo_max = ammo_max
end
end
self.store_mode_is_enabled = store_mode_is_enabled
if store_mode_is_enabled == false then
-- Determines if we show ammo or not... based on if there is no ammo in the clip.
local has_ammo = true
if ammo_max >= 1 and ammo_cur < 1 then
has_ammo = false
end
if ammo_infinite then
has_ammo = true
end
if availability and has_ammo then
self.is_enabled = true
else
self.is_enabled = false
end
end
self.weapon_name = weapon_name
if weapon_name_crc ~= self.weapon_name_crc or dual_wield ~= self.dual_wield or weapon_bmp_name ~= self.weapon_bmp_name or Store_weapon_is_loaded == true then
if weapon_bmp_name == nil then
--No weapon, so hide other elements
local ammo_bar_fill_bmp = Vdo_base_object:new("ammo_circle", self.handle, self.doc_handle)
local ammo_bar_bg_bmp = Vdo_base_object:new("ammo_bg", self.handle, self.doc_handle)
local infinity_bmp = Vdo_base_object:new("infinity_bmp", self.handle, self.doc_handle)
ammo_bar_fill_bmp:set_visible(false)
ammo_bar_bg_bmp:set_visible(false)
infinity_bmp:set_visible(false)
if slot_num < 8 then
dual_inv_1_bmp:set_visible(false)
dual_inv_2_bmp:set_visible(false)
end
-- Show placeholder weapon icon
if store_mode_is_enabled and cache_is_enabled ~= true then
dual_inv_1_bmp:set_anchor(0, 0)
dual_inv_1_bmp:set_image(Weapon_store_images[slot_num])
dual_inv_1_bmp:set_visible(true)
self.is_outline = true
end
else
--Change Weapon bitmap
dual_inv_1_bmp:set_image(weapon_bmp_name)
dual_inv_2_bmp:set_image(weapon_bmp_name)
--Check if Dual wielding for formating differences
if dual_wield == true then
--Dual Wield Weapon
dual_inv_1_bmp:set_visible(true)
dual_inv_2_bmp:set_visible(true)
--Reposition to stored values in init()
dual_inv_1_bmp:set_anchor(Vdo_weapon_radial_slot_dual_1_x, Vdo_weapon_radial_slot_dual_1_y)
dual_inv_2_bmp:set_anchor(Vdo_weapon_radial_slot_dual_2_x, Vdo_weapon_radial_slot_dual_2_y)
else
--Single Wield Weapon
dual_inv_1_bmp:set_anchor(0, 0)
dual_inv_1_bmp:set_visible(true)
dual_inv_2_bmp:set_visible(false)
end
--Exception for layer depth for the following weapon bitmaps.
--We want these bitmaps to draw in front of the ammo bar.
if weapon_bmp_name == "ui_hud_inv_w_ar50grenade" or weapon_bmp_name == "ui_hud_inv_w_minigun" or weapon_bmp_name == "ui_hud_inv_w_flamethrower" then
dual_inv_1_bmp:set_depth(-400)
dual_inv_2_bmp:set_depth(-300)
else
dual_inv_1_bmp:get_depth(-200)
dual_inv_2_bmp:get_depth(-100)
end
end
self.dual_wield = dual_wield
self.weapon_bmp_name = weapon_bmp_name
self.weapon_name_crc = weapon_name_crc
self.weapon_class_crc = weapon_class_crc
end
local gold_upgrade_bmp_h = vint_object_find("icon_upgrade_icon", self.handle, self.doc_handle)
if ui_hud_is_weapon_fully_upgraded(weapon_name) then
vint_set_property(gold_upgrade_bmp_h, "visible", true)
else
vint_set_property(gold_upgrade_bmp_h, "visible", false)
end
local sin_bmp_h = vint_object_find("icon_seven_sins", self.handle, self.doc_handle)
if is_seven_deadly_sin then
vint_set_property(sin_bmp_h, "visible", true)
else
vint_set_property(sin_bmp_h, "visible", false)
end
--element
--local element = 8
if element ~= nil and element ~= -1 then
if element ~= self.element then
vint_set_property(element_bmp_h, "image", POWERS_ELEMENTS_ENUMS[element].bitmap)
vint_set_property(element_bmp_h, "visible", true)
end
else
vint_set_property(element_bmp_h, "visible", false)
end
self.element = element
self.availability = availability
self.level = level
self.slot_num = slot_num
self.ammo_type = ammo_type
if store_mode_is_enabled == false then
--Updates state of radial slot
self:redraw()
end
end
function Vdo_weapon_radial_slot:update_element(element)
local element_bmp_h = vint_object_find("element_bmp", self.handle, self.doc_handle)
if element ~= nil and element ~= -1 then
if element ~= self.element then
vint_set_property(element_bmp_h, "image", POWERS_ELEMENTS_ENUMS[element].bitmap)
vint_set_property(element_bmp_h, "visible", true)
end
else
vint_set_property(element_bmp_h, "visible", false)
end
self.element = element
end
function Vdo_weapon_radial_slot:set_highlight(is_highlighted)
if is_highlighted == nil then
is_highlighted = self.is_highlighted
end
self.is_highlighted = is_highlighted
self:redraw()
end
function Vdo_weapon_radial_slot:set_enabled(is_enabled)
self.is_enabled = is_enabled
self:redraw()
end
function Vdo_weapon_radial_slot:redraw()
local dual_inv_1_bmp_h = vint_object_find("dual_inv_1_bmp", self.handle, self.doc_handle)
local dual_inv_2_bmp_h = vint_object_find("dual_inv_2_bmp", self.handle, self.doc_handle)
local ammo_circle_h = vint_object_find("ammo_circle", self.handle, self.doc_handle)
local base_bmp_h = vint_object_find("base_bmp", self.handle, self.doc_handle)
local element_bmp_h = vint_object_find("element_bmp", self.handle, self.doc_handle)
if self.weapon_bmp_name ~= nil then
vint_set_property(dual_inv_1_bmp_h, "visible", true)
if self.element ~= nil and self.element ~= -1 then
vint_set_property(element_bmp_h, "visible", true)
else
vint_set_property(element_bmp_h, "visible", false)
end
else
-- If we're in the store and don't have a weapon for a category show a generic
-- outline weapon icon.
if self.is_outline == true then
vint_set_property(dual_inv_1_bmp_h, "visible", true)
vint_set_property(dual_inv_2_bmp_h, "visible", false)
else
vint_set_property(dual_inv_1_bmp_h, "visible", false)
vint_set_property(dual_inv_2_bmp_h, "visible", false)
end
vint_set_property(element_bmp_h, "visible", false)
end
--Set visuals based on weapon availability
if self.is_highlighted then
if self.is_enabled or self.weapon_name == "Explosive-Ark" then
--Highlighted and Enabeled
vint_set_property(dual_inv_1_bmp_h, "tint", 1, 1, 1)
vint_set_property(dual_inv_2_bmp_h, "tint", 1, 1, 1)
vint_set_property(base_bmp_h, "visible", false)
vint_set_property(ammo_circle_h, "alpha", 1)
vint_set_property(element_bmp_h, "tint", 1, 1, 1)
vint_set_property(element_bmp_h, "alpha", 1)
else
--Highlighted and Disabled
vint_set_property(dual_inv_1_bmp_h, "tint", .15, .15, .15)
vint_set_property(dual_inv_2_bmp_h, "tint", .15, .15, .15)
vint_set_property(base_bmp_h, "tint", .15, .15, .15)
vint_set_property(base_bmp_h, "visible", false)
vint_set_property(ammo_circle_h, "alpha", .5)
vint_set_property(element_bmp_h, "tint", .15, .15, .15)
vint_set_property(element_bmp_h, "alpha", 1)
end
else
if self.is_enabled or self.weapon_name == "Explosive-Ark" then
--Not Highlighted and Enabeled
vint_set_property(dual_inv_1_bmp_h, "tint", .65, .65, .65)
vint_set_property(dual_inv_2_bmp_h, "tint", .65, .65, .65)
vint_set_property(base_bmp_h, "tint", .15, .15, .15)
vint_set_property(base_bmp_h, "visible", true)
vint_set_property(ammo_circle_h, "alpha", .5)
vint_set_property(element_bmp_h, "tint", .65, .65, .65)
vint_set_property(element_bmp_h, "alpha", 1)
else
--Not Highlighted and Disabled
--Are we in the store?
if self.store_mode_is_enabled then
--Make disabled slots darker in store
vint_set_property(dual_inv_1_bmp_h, "tint", .10, .10, .10)
vint_set_property(dual_inv_2_bmp_h, "tint", .10, .10, .10)
vint_set_property(base_bmp_h, "tint", .10, .10, .10)
vint_set_property(base_bmp_h, "visible", true)
vint_set_property(ammo_circle_h, "alpha", .35)
vint_set_property(element_bmp_h, "tint", .10, .10, .10)
vint_set_property(element_bmp_h, "alpha", 1)
else
vint_set_property(dual_inv_1_bmp_h, "tint", .25, .25, .25)
vint_set_property(dual_inv_2_bmp_h, "tint", .25, .25, .25)
vint_set_property(base_bmp_h, "tint", .15, .15, .15)
vint_set_property(base_bmp_h, "visible", true)
vint_set_property(ammo_circle_h, "alpha", .65)
vint_set_property(element_bmp_h, "tint", .15, .15, .15)
vint_set_property(element_bmp_h, "alpha", 1)
end
end
end
end
function Vdo_weapon_radial_slot:show_ammo(is_visible)
local ammo_bg_h = vint_object_find("ammo_bg", self.handle, self.doc_handle)
local ammo_circle_h = vint_object_find("ammo_circle", self.handle, self.doc_handle)
vint_set_property(ammo_bg_h, "visible", is_visible)
vint_set_property(ammo_circle_h, "visible", is_visible)
end
function Vdo_weapon_radial_slot:has_infinite_ammo()
if self.ammo_infinite then
return true
else
return false
end
end