preserve settings across restart
This commit is contained in:
parent
26e07efb11
commit
cf286c5ebb
|
@ -1,6 +1,6 @@
|
|||
on.initialize = function()
|
||||
love.graphics.setFont(love.graphics.newFont(20))
|
||||
Line_height = math.floor(love.graphics.getFont():getHeight()*1.3)
|
||||
love.graphics.setFont(love.graphics.newFont(Font_height))
|
||||
Line_height = math.floor(Font_height*1.3)
|
||||
Line_number_padding = Line_number_width*App.width('m')
|
||||
Menu_left, Menu_top, Safe_width, Safe_height = love.window.getSafeArea()
|
||||
Menu_height = 5 + Line_height + 5
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
update_font_settings = function(font_height)
|
||||
Font_height = font_height
|
||||
love.graphics.setFont(love.graphics.newFont(font_height))
|
||||
Line_height = math.floor(love.graphics.getFont():getHeight()*1.3)
|
||||
Line_height = math.floor(font_height*1.3)
|
||||
Line_number_padding = Line_number_width*App.width('m')
|
||||
Menu_height = 5 + Line_height + 5
|
||||
Menu_bottom = Menu_top + Menu_height
|
||||
|
|
|
@ -4,7 +4,7 @@ copy_editor = function(state)
|
|||
Safe_height/2-Line_height, -- bottom
|
||||
Menu_left + 50 + Line_number_padding, -- left
|
||||
math.min(100+30*App.width('m'), Safe_width*2/3), -- right
|
||||
love.graphics.getFont():getHeight(), Line_height)
|
||||
Font_height, Line_height)
|
||||
new_state.lines = map(state.lines,
|
||||
function(line)
|
||||
return {data=line.data}
|
||||
|
|
|
@ -3,7 +3,7 @@ output_editor_state = function(editor_state)
|
|||
editor_state.bottom+5+10+5, -- top
|
||||
nil, -- buttom
|
||||
editor_state.left, editor_state.right,
|
||||
love.graphics.getFont():getHeight(), Line_height)
|
||||
Font_height, Line_height)
|
||||
Text.redraw_all(result)
|
||||
return result
|
||||
end
|
|
@ -4,7 +4,7 @@ code_editor_state = function()
|
|||
Safe_height/2-Line_height, -- bottom
|
||||
Menu_left + 50 + Line_number_padding, -- left
|
||||
math.min(100+30*App.width('m'), Safe_width*2/3), -- right
|
||||
love.graphics.getFont():getHeight(), Line_height)
|
||||
Font_height, Line_height)
|
||||
Text.redraw_all(result)
|
||||
return result
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
draw_settings_menu = function()
|
||||
App.color(Menu_background)
|
||||
local w,h = 200, love.graphics.getFont():getHeight()*8
|
||||
local w,h = 200, Font_height*8
|
||||
local x,y = Safe_width-30-w, Menu_bottom
|
||||
Settings_menu_area = {x=x, y=y, w=w, h=h}
|
||||
love.graphics.rectangle('fill', x,y, w,h)
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Font_height = 20
|
|
@ -0,0 +1,7 @@
|
|||
on.save_settings = function()
|
||||
return {
|
||||
font_height = Font_height,
|
||||
foreground_color = Foreground_color,
|
||||
background_color = Background_color
|
||||
}
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
on.load_settings = function(settings)
|
||||
Font_height = settings.font_height or font_height
|
||||
Background_color = settings.background_color or Background_color
|
||||
-- careful not to replace the Foreground_color table instance
|
||||
if settings.foreground_color then
|
||||
local src = settings.foreground_color
|
||||
local dest = Foreground_color
|
||||
dest.r, dest.g, dest.b, dest.a = src.r, src.g, src.b, src.a
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue