Skip to content

Commit 542d408

Browse files
authored
Merge pull request #1360 from myk002/myk_rating_xp
[gui/unit-info-viewer]: use xp formula instead of limited range of enum values
2 parents be28ff1 + 6545b28 commit 542d408

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Template for new versions:
3535

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

3940
## Misc Improvements
4041
- `immortal-cravings`: goblins and other naturally non-eating/non-drinking races will now also satisfy their needs for eating and drinking

internal/unit-info-viewer/skills-progress.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ SkillProgressOverlay.ATTRS {
2727
'dwarfmode/ViewSheets/UNIT/Skills/Combat',
2828
'dwarfmode/ViewSheets/UNIT/Skills/Social',
2929
'dwarfmode/ViewSheets/UNIT/Skills/Other',
30-
3130
'dungeonmode/ViewSheets/UNIT/Skills/Labor',
3231
'dungeonmode/ViewSheets/UNIT/Skills/Combat',
3332
'dungeonmode/ViewSheets/UNIT/Skills/Social',
@@ -79,6 +78,10 @@ function SkillProgressOverlay:preUpdateLayout(parent_rect)
7978
self.frame.h = parent_rect.height - 21
8079
end
8180

81+
local function get_threshold(lvl)
82+
return 500 + lvl * 100
83+
end
84+
8285
function SkillProgressOverlay:onRenderFrame(dc, rect)
8386
local annotations = {}
8487
local current_unit = df.unit.find(view_sheets.active_id)
@@ -104,7 +107,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect)
104107
table.insert(annotations, "\n\n\n\n")
105108
goto continue
106109
end
107-
local rating = df.skill_rating.attrs[math.max(df.skill_rating.Dabbling, math.min(skill.rating, df.skill_rating.Legendary5))]
110+
local xp_threshold = get_threshold(skill.rating)
108111
if experience then
109112
if not progress_bar then
110113
table.insert(annotations, NEWLINE)
@@ -122,7 +125,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect)
122125
pen=level_color,
123126
})
124127
table.insert(annotations, {
125-
text=('%4d/%4d'):format(skill.experience, rating.xp_threshold),
128+
text=('%4d/%4d'):format(skill.experience, xp_threshold),
126129
pen=level_color,
127130
width=9,
128131
rjustify=true,
@@ -134,7 +137,7 @@ function SkillProgressOverlay:onRenderFrame(dc, rect)
134137
-- Progress Bar
135138
if progress_bar then
136139
table.insert(annotations, NEWLINE)
137-
local percentage = skill.experience / rating.xp_threshold
140+
local percentage = skill.experience / xp_threshold
138141
local barstop = math.floor((margin * percentage) + 0.5)
139142
for i = 0, margin-1 do
140143
local color = COLOR_LIGHTCYAN

0 commit comments

Comments
 (0)