25 lines
684 B
Plaintext
25 lines
684 B
Plaintext
manifest_index = function(fy, fx, fwidth)
|
|
local y,x = Menu_bar_height, 5
|
|
local best_guess, best_guess_x, best_guess_width
|
|
for i,definition in ipairs(Manifest_navigator.candidates) do
|
|
local width = to_hud_text(definition):getWidth()
|
|
if x + width > App.screen.width - 5 then
|
|
y = y + HUD_line_height
|
|
x = 5
|
|
end
|
|
if y == fy then
|
|
if best_guess == nil then
|
|
best_guess = i
|
|
best_guess_x = x
|
|
best_guess_width = width
|
|
elseif math.abs(fx + fwidth/2 - x - width/2) < math.abs(fx + fwidth/2 - best_guess_x - best_guess_width/2) then
|
|
best_guess = i
|
|
best_guess_x = x
|
|
best_guess_width = width
|
|
end
|
|
end
|
|
x = x + width + 30
|
|
end
|
|
return best_guess
|
|
end
|