Skip to content

Commit

Permalink
Fix some Resource texts being locked on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
UTDZac committed Apr 18, 2024
1 parent 21ea080 commit acb9842
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
13 changes: 8 additions & 5 deletions ironmon_tracker/screens/ExtrasScreen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,17 @@ function ExtrasScreen.createTabs()
local tabPadding = 6

for _, tuple in ipairs(tabs) do
local tabText = Resources.ExtrasScreen[tuple[2]]
local tabWidth = (tabPadding * 2) + Utils.calcWordPixelLength(tabText)
ExtrasScreen.Buttons["Tab" .. tuple[1]] = {
type = Constants.ButtonTypes.NO_BORDER,
getText = function(self) return tabText end,
getText = function(self) return Resources.ExtrasScreen[tuple[2]] end,
tab = ExtrasScreen.Tabs[tuple[1]],
isSelected = false,
box = { startX, startY, tabWidth, tabHeight },
box = {
startX,
startY,
(tabPadding * 2) + Utils.calcWordPixelLength(Resources.ExtrasScreen[tuple[2]]),
tabHeight
},
updateSelf = function(self)
self.isSelected = (self.tab == ExtrasScreen.currentTab)
self.textColor = self.isSelected and ExtrasScreen.Colors.highlight or ExtrasScreen.Colors.text
Expand Down Expand Up @@ -186,7 +189,7 @@ function ExtrasScreen.createTabs()
Program.redraw(true)
end,
}
startX = startX + tabWidth
startX = startX + (tabPadding * 2) + Utils.calcWordPixelLength(Resources.ExtrasScreen[tuple[2]])
end
end

Expand Down
23 changes: 15 additions & 8 deletions ironmon_tracker/screens/SetupScreen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,17 @@ function SetupScreen.createTabs()
local tabPadding = 6

for _, tab in ipairs(Utils.getSortedList(SCREEN.Tabs)) do
local tabText = Resources.SetupScreen[tab.resourceKey]
local tabWidth = (tabPadding * 2) + Utils.calcWordPixelLength(tabText)
SCREEN.Buttons["Tab" .. tab.tabKey] = {
type = Constants.ButtonTypes.NO_BORDER,
getText = function(self) return tabText end,
getText = function(self) return Resources.SetupScreen[tab.resourceKey] end,
tab = SCREEN.Tabs[tab.tabKey],
isSelected = false,
box = { startX, startY, tabWidth, TAB_HEIGHT },
box = {
startX,
startY,
(tabPadding * 2) + Utils.calcWordPixelLength(Resources.SetupScreen[tab.resourceKey]),
TAB_HEIGHT
},
updateSelf = function(self)
self.isSelected = (self.tab == SCREEN.currentTab)
self.textColor = self.isSelected and SCREEN.Colors.highlight or SCREEN.Colors.text
Expand Down Expand Up @@ -218,7 +221,7 @@ function SetupScreen.createTabs()
Program.redraw(true)
end,
}
startX = startX + tabWidth
startX = startX + (tabPadding * 2) + Utils.calcWordPixelLength(Resources.SetupScreen[tab.resourceKey])
end
end

Expand Down Expand Up @@ -266,11 +269,15 @@ function SetupScreen.createButtons()
startX = Constants.SCREEN.WIDTH + Constants.SCREEN.MARGIN + 4
startY = Constants.SCREEN.MARGIN + 38

local speedText = string.format("%s:", Resources.SetupScreen.LabelSpeedSetting)
SCREEN.Buttons.CarouselSpeedHeader = {
type = Constants.ButtonTypes.NO_BORDER,
getText = function(self) return speedText end,
box = { startX - 3, startY, Utils.calcWordPixelLength(speedText) + 5, 11 },
getText = function(self) return string.format("%s:", Resources.SetupScreen.LabelSpeedSetting) end,
box = {
startX - 3,
startY,
Utils.calcWordPixelLength(string.format("%s:", Resources.SetupScreen.LabelSpeedSetting)) + 5,
11
},
isVisible = function(self) return SCREEN.currentTab == SCREEN.Tabs.Carousel end,
}
startX = startX + 32
Expand Down

0 comments on commit acb9842

Please sign in to comment.