use a helper
This commit is contained in:
parent
620176263a
commit
cea2730080
18
commands.lua
18
commands.lua
|
@ -42,15 +42,13 @@ function source.draw_menu_bar()
|
||||||
end
|
end
|
||||||
|
|
||||||
function add_hotkey_to_menu(s)
|
function add_hotkey_to_menu(s)
|
||||||
if Text_cache[s] == nil then
|
local s_text = to_text(s)
|
||||||
Text_cache[s] = App.newText(love.graphics.getFont(), s)
|
local width = App.width(s_text)
|
||||||
end
|
|
||||||
local width = App.width(Text_cache[s])
|
|
||||||
if Menu_cursor + width > App.screen.width - 5 then
|
if Menu_cursor + width > App.screen.width - 5 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
App.color(Menu_command_color)
|
App.color(Menu_command_color)
|
||||||
App.screen.draw(Text_cache[s], Menu_cursor,5)
|
App.screen.draw(s_text, Menu_cursor,5)
|
||||||
Menu_cursor = Menu_cursor + width + 30
|
Menu_cursor = Menu_cursor + width + 30
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -68,20 +66,18 @@ function source.draw_file_navigator()
|
||||||
end
|
end
|
||||||
|
|
||||||
function add_file_to_menu(s, cursor_highlight)
|
function add_file_to_menu(s, cursor_highlight)
|
||||||
if Text_cache[s] == nil then
|
local s_text = to_text(s)
|
||||||
Text_cache[s] = App.newText(love.graphics.getFont(), s)
|
local width = App.width(s_text)
|
||||||
end
|
|
||||||
local width = App.width(Text_cache[s])
|
|
||||||
if Menu_cursor + width > App.screen.width - 5 then
|
if Menu_cursor + width > App.screen.width - 5 then
|
||||||
log(2, 'skipped')
|
log(2, 'skipped')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if cursor_highlight then
|
if cursor_highlight then
|
||||||
App.color(Menu_highlight_color)
|
App.color(Menu_highlight_color)
|
||||||
love.graphics.rectangle('fill', Menu_cursor-5,5-2, App.width(Text_cache[s])+5*2,Editor_state.line_height+2*2)
|
love.graphics.rectangle('fill', Menu_cursor-5,5-2, App.width(s_text)+5*2,Editor_state.line_height+2*2)
|
||||||
end
|
end
|
||||||
App.color(Menu_command_color)
|
App.color(Menu_command_color)
|
||||||
App.screen.draw(Text_cache[s], Menu_cursor,5)
|
App.screen.draw(s_text, Menu_cursor,5)
|
||||||
Menu_cursor = Menu_cursor + width + 30
|
Menu_cursor = Menu_cursor + width + 30
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue