Skip to content

Commit

Permalink
Merge pull request #38 from snuk182/bugfix-choice-font
Browse files Browse the repository at this point in the history
Fix #37
  • Loading branch information
ajusa authored Feb 11, 2023
2 parents 5024aaf + ffb76b6 commit e745320
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/listbox.moon
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ create_listbox = =>
dispatch "pause"
font_height = (text) ->
_, count = string.gsub(remove_color(text), "\n", "\n")
return math.max(font\getHeight! * (1 + count), @media)
return math.max(text_font\getHeight! * (1 + count), @media)
close = ->
input_event\remove!
draw_event\remove!
Expand All @@ -47,7 +47,8 @@ create_listbox = =>
if chosen.left then chosen.left(chosen)
return false
draw_event = on "draw_choice", ->
w = 3 * pad + _.max([font\getWidth(remove_color(c.text)) for c in *@choices]) + @media
lg.setFont(text_font)
w = 3 * pad + _.max([text_font\getWidth(remove_color(c.text)) for c in *@choices]) + @media
h, y_selected = pad, 0
for i, c in ipairs @choices
h += font_height(c.text) + pad
Expand All @@ -63,5 +64,6 @@ create_listbox = =>
if i == @selected then lg.setColor(.506, .631, .757)
lg.print(c.text, x + 2*pad + @media, text_y)
text_y += pad + font_height(c.text)
lg.setFont(font)
return false
return {:create_listbox}
2 changes: 2 additions & 0 deletions src/main.moon
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ original_width, original_height = lg.getWidth!,lg.getHeight!
-- love.filesystem.write('profile.txt', profile.report(40))

font = nil
text_font = nil
love.resize = (w, h) ->
sx, sy = w / original_width, h / original_height
px, py = w/256, h/192 --resolution of the DS
font_size = 32 -- fix the font scaling to work based on resolution
if w < 600 then font_size = 20
lg.setNewFont(font_size)
font = lg.getFont!
text_font = font
dispatch "resize", {:sx, :sy, :px, :py}
next_msg = (ins) ->
if ins == nil
Expand Down
1 change: 0 additions & 1 deletion src/text/text.moon
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ backlog = {}
lines = 3
if love._console_name == "3DS" then lines = 7
pad = 10
text_font = font
override_font = nil
update_font = ->
if interpreter and not override_font
Expand Down

0 comments on commit e745320

Please sign in to comment.