diff --git a/src/listbox.moon b/src/listbox.moon index dcf9562..d72986c 100644 --- a/src/listbox.moon +++ b/src/listbox.moon @@ -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! @@ -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 @@ -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} diff --git a/src/main.moon b/src/main.moon index 3af63de..b53fedb 100644 --- a/src/main.moon +++ b/src/main.moon @@ -30,6 +30,7 @@ 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 @@ -37,6 +38,7 @@ love.resize = (w, h) -> 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 diff --git a/src/text/text.moon b/src/text/text.moon index 04f1fca..5cd88f2 100644 --- a/src/text/text.moon +++ b/src/text/text.moon @@ -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