Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 12 additions & 24 deletions ui_improvements/scripts/mods/ui_improvements/ui_improvements.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ mod:dofile("scripts/mods/ui_improvements/ui_improvements_items")
mod:dofile("scripts/mods/ui_improvements/ui_improvements_crafting")
--mod:dofile("scripts/mods/ui_improvements/ui_improvements_salvage")
mod:dofile("scripts/mods/ui_improvements/ui_improvements_cosmetics")
mod:dofile("scripts/mods/ui_improvements/ui_improvements_loot")
--mod:dofile("scripts/mods/ui_improvements/ui_improvements_loot")
mod:dofile("scripts/mods/ui_improvements/ui_improvements_deeds")
mod:dofile("scripts/mods/ui_improvements/ui_improvements_achievements")
--mod:dofile("scripts/mods/ui_improvements/ui_improvements_achievements")

-- ##### ██████╗ █████╗ ████████╗ █████╗ #############################################################################
-- ##### ██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗ ############################################################################
Expand Down Expand Up @@ -45,8 +45,7 @@ mod.window_settings = {
Get hero view and check if view is open
--]]
mod.get_hero_view = function(self)
local matchmaking_manager = Managers.matchmaking
local ingame_ui = matchmaking_manager and matchmaking_manager._ingame_ui
local ingame_ui = Managers.ui:temporary_get_ingame_ui_called_from_state_ingame_running()
local hero_view_active = ingame_ui and ingame_ui.current_view == "hero_view"
local hero_view = hero_view_active and ingame_ui.views["hero_view"]

Expand Down Expand Up @@ -75,20 +74,7 @@ mod.overwrite_functions = function(self, overwrite)

-- Overwrite profile function
ingame_ui_context.profile_synchronizer.profile_by_peer = function(self, peer_id, local_player_id)
return mod.profile_index or mod.orig_profile_by_peer(self, peer_id, local_player_id)
end

-- Backup original career function
if not mod.orig_get_career then
mod.orig_get_career = Managers.backend._interfaces["hero_attributes"].get
end

-- Overwrite career function
Managers.backend._interfaces["hero_attributes"].get = function(self, hero_name, attribute_name)
if attribute_name == "career" then
return mod.career_index or mod.orig_get_career(self, hero_name, attribute_name)
end
return mod.orig_get_career(self, hero_name, attribute_name)
return mod.profile_index, mod.career_index or mod.orig_profile_by_peer(self, peer_id, local_player_id)
end

else
Expand All @@ -99,12 +85,6 @@ mod.overwrite_functions = function(self, overwrite)
mod.orig_profile_by_peer = nil
end

-- Reset career function
if mod.orig_get_career then
Managers.backend._interfaces["hero_attributes"].get = mod.orig_get_career
mod.orig_get_career = nil
end

end
end
--[[
Expand Down Expand Up @@ -143,6 +123,14 @@ mod:hook(HeroView, "_change_screen_by_name", function(func, self, screen_name, s
elseif screen_name ~= "loot" then
mod:delete_profile_data()
end

if optional_params == nil then
optional_params = {}
end
if optional_params.force_ingame_menu == nil then
optional_params.force_ingame_menu = false
end

-- Orig function
func(self, screen_name, sub_screen_name, optional_params, ...)
end)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,23 @@ mod.career_unlocked = function(self, profile_index, career_index)
local unlocked = false

local profile_settings = SPProfiles[profile_index]
local display_name = profile_settings.display_name
local hero_name = profile_settings.display_name

local career = profile_settings.careers[career_index]

local hero_attributes = Managers.backend:get_interface("hero_attributes")
local hero_experience = hero_attributes:get(display_name, "experience") or 0
local hero_experience = hero_attributes:get(hero_name, "experience") or 0
local hero_level = ExperienceSettings.get_level(hero_experience)

local career_name = SPProfiles[profile_index].careers[career_index].name

unlocked = ProgressionUnlocks.is_unlocked_for_profile(career_name, display_name, hero_level)
local is_career_unlocked = career:is_unlocked_function(hero_name, hero_level)

return unlocked
return is_career_unlocked
end
--[[
Get protrait frame for given profile and career
--]]
mod.get_portrait_frame = function(self, profile_index, career_index)
local player_portrait_frame = "default"
local player_portrait_frame = "portrait_frame_0000"

local profile = SPProfiles[profile_index]
local career_data = profile.careers[career_index]
Expand All @@ -58,6 +58,7 @@ mod.get_portrait_frame = function(self, profile_index, career_index)
player_portrait_frame = frame_texture or player_portrait_frame
end

mod:debug("Retrieved portrait " .. tostring(player_portrait_frame) .. "\tProfile " .. profile_index .. "\tCareer " .. career_index)
return player_portrait_frame
end
--[[
Expand Down Expand Up @@ -180,6 +181,7 @@ end
Change character
--]]
mod.change_character = function(self, profile_index)
mod:debug("Changing character to " .. profile_index)
if mod.profile_index ~= profile_index then

-- Set selected profile index
Expand All @@ -191,6 +193,7 @@ mod.change_character = function(self, profile_index)
local hero_attributes = Managers.backend:get_interface("hero_attributes")
local career_index = not mod.orig_get_career and hero_attributes:get(display_name, "career") or mod.orig_get_career(hero_attributes, display_name, "career")
mod.career_index = career_index
mod:debug("Got career index for change: " .. career_index)

-- Delete career widgets ( because not all characters have the same amount of careers now )
mod.career_widgets = {}
Expand All @@ -210,7 +213,7 @@ end
Create career button widget
--]]
mod.create_career_button = function(self, profile_index, career_index)

mod:debug("Creating career button. Profile " .. profile_index .. "\tCareer " .. career_index)
-- Values
local root = {200, 40, 20}
local size = {60, 70}
Expand Down Expand Up @@ -326,6 +329,7 @@ end
Change career
--]]
mod.change_career = function(self, profile_index, career_index)
mod:debug("Changing career. Profile " .. profile_index .. "\tCareer " .. career_index)

-- Set selected profile index
mod.profile_index = profile_index
Expand Down Expand Up @@ -479,6 +483,7 @@ mod:hook_safe(HeroWindowOptions, "post_update", function(self, ...)
-- Career buttons
for _, widget in pairs(mod.career_widgets) do
if not widget.content.disable_button and self:_is_button_pressed(widget) then
mod:debug("Attempting to switch to profile ".. widget.content.profile_index .. " career ".. widget.content.career_index)
mod:change_career(widget.content.profile_index, widget.content.career_index)
end
end
Expand Down