Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gui/unit-info-viewer]: use xp formula instead of limited range of enum values #1360

Merged
merged 1 commit into from
Dec 29, 2024
Merged
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
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Template for new versions:

## Fixes
- `fix/dry-buckets`: don't empty buckets for wells that are actively in use
- `gui/unit-info-viewer`: skill progress bars now show correct XP thresholds for skills past Legendary+5

## Misc Improvements
- `immortal-cravings`: goblins and other naturally non-eating/non-drinking races will now also satisfy their needs for eating and drinking
Expand Down
11 changes: 7 additions & 4 deletions internal/unit-info-viewer/skills-progress.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ SkillProgressOverlay.ATTRS {
'dwarfmode/ViewSheets/UNIT/Skills/Combat',
'dwarfmode/ViewSheets/UNIT/Skills/Social',
'dwarfmode/ViewSheets/UNIT/Skills/Other',

'dungeonmode/ViewSheets/UNIT/Skills/Labor',
'dungeonmode/ViewSheets/UNIT/Skills/Combat',
'dungeonmode/ViewSheets/UNIT/Skills/Social',
Expand Down Expand Up @@ -79,6 +78,10 @@ function SkillProgressOverlay:preUpdateLayout(parent_rect)
self.frame.h = parent_rect.height - 21
end

local function get_threshold(lvl)
return 500 + lvl * 100
end

function SkillProgressOverlay:onRenderFrame(dc, rect)
local annotations = {}
local current_unit = df.unit.find(view_sheets.active_id)
Expand All @@ -104,7 +107,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect)
table.insert(annotations, "\n\n\n\n")
goto continue
end
local rating = df.skill_rating.attrs[math.max(df.skill_rating.Dabbling, math.min(skill.rating, df.skill_rating.Legendary5))]
local xp_threshold = get_threshold(skill.rating)
if experience then
if not progress_bar then
table.insert(annotations, NEWLINE)
Expand All @@ -122,7 +125,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect)
pen=level_color,
})
table.insert(annotations, {
text=('%4d/%4d'):format(skill.experience, rating.xp_threshold),
text=('%4d/%4d'):format(skill.experience, xp_threshold),
pen=level_color,
width=9,
rjustify=true,
Expand All @@ -134,7 +137,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect)
-- Progress Bar
if progress_bar then
table.insert(annotations, NEWLINE)
local percentage = skill.experience / rating.xp_threshold
local percentage = skill.experience / xp_threshold
local barstop = math.floor((margin * percentage) + 0.5)
for i = 0, margin-1 do
local color = COLOR_LIGHTCYAN
Expand Down
Loading