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

TastyText line length fix for love.js #2601

Merged
merged 1 commit into from
Nov 23, 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
6 changes: 4 additions & 2 deletions src/nodes/npc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ function Menu:keypressed( button, player )
elseif item.text == 'inventory' then
if self.host.props.inventory then
self:instahide()
self.host.props.inventory(self.host, player)
self.dialog = Dialog.new(self.responses[item.text], function() self:show() end)
self.dialog = Dialog.new(self.responses[item.text], function()
self.host.props.inventory(self.host, player)
self:show()
end)
else
self:hide()
self.dialog = Dialog.new(self.host.noinventory, function() self:show() end)
Expand Down
2 changes: 1 addition & 1 deletion src/tooltip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Tooltip:draw(x, y, selectedItem, parent)
tastytext = fonts.tasty.new(itemStats, textX, textY + (descriptionWrap * lineHeight), textWidth, love.graphics.getFont(), fonts.colors, lineHeight)
statWrap = tastytext.lines
tastytext:draw()
drawSeparator(textX, textY + (descriptionWrap + statWrap) * lineHeight, textWidth)
drawSeparator(textX, textY + ((descriptionWrap + statWrap) * lineHeight), textWidth)
end

-- Lastly, insert our item information after everything else
Expand Down
8 changes: 7 additions & 1 deletion src/vendor/tastytext/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ function TastyText:_getMetaData()
local line_lengths = {}
local line_widths = {}
local length = 0
local lines = 1
for i = 1,#self.chunk_array do
local chunk = self.chunk_array[i]
if chunk.length then
Expand All @@ -244,7 +245,12 @@ function TastyText:_getMetaData()
(line_widths[chunk.line] or 0) + chunk.width
end
end
return #line_lengths,length,line_lengths,line_widths
-- NOTE: This is a love.js workaround.
-- Returning #line_lengths always results in 0 in love.js for some reason.
for k,v in pairs(line_lengths) do
lines = lines + 1
end
return lines,length,line_lengths,line_widths
end

function TastyText:_parseString(str)
Expand Down