parent
119f406d3c
commit
f250adcda1
|
@ -469,12 +469,15 @@ function core.init()
|
||||||
local msg = {}
|
local msg = {}
|
||||||
for _, entry in pairs(plugins_refuse_list) do
|
for _, entry in pairs(plugins_refuse_list) do
|
||||||
if #entry.plugins > 0 then
|
if #entry.plugins > 0 then
|
||||||
msg[#msg + 1] = string.format("from %s: %s", common.home_encode(entry.dir), table.concat(entry.plugins, ", "))
|
msg[#msg + 1] = string.format("Plugins from directory \"%s\":\n%s", common.home_encode(entry.dir), table.concat(entry.plugins, "\n"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
core.nag_view:show(
|
core.nag_view:show(
|
||||||
"Refused Plugins",
|
"Refused Plugins",
|
||||||
string.format("Refused plugins %s", table.concat(msg, " and ")),
|
string.format(
|
||||||
|
"Some plugins are not loaded due to version mismatch.\n\n%s.\n\n" ..
|
||||||
|
"Please download a recent version from https://github.com/franko/lite-plugins.",
|
||||||
|
table.concat(msg, ".\n\n")),
|
||||||
opt, function(item)
|
opt, function(item)
|
||||||
if item.text == "Exit" then os.exit(1) end
|
if item.text == "Exit" then os.exit(1) end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
local core = require "core"
|
local core = require "core"
|
||||||
local command = require "core.command"
|
local command = require "core.command"
|
||||||
local common = require "core.common"
|
local common = require "core.common"
|
||||||
|
local config = require "core.config"
|
||||||
local View = require "core.view"
|
local View = require "core.view"
|
||||||
local style = require "core.style"
|
local style = require "core.style"
|
||||||
|
|
||||||
|
@ -23,24 +24,33 @@ function NagView:get_title()
|
||||||
return self.title
|
return self.title
|
||||||
end
|
end
|
||||||
|
|
||||||
function NagView:get_options_line_height()
|
-- The two methods below are duplicated from DocView
|
||||||
local max = 0
|
function NagView:get_line_height()
|
||||||
for _, opt in ipairs(self.options) do
|
return math.floor(style.font:get_height() * config.line_height)
|
||||||
local lh = style.font:get_height(opt.text)
|
|
||||||
if lh > max then max = lh end
|
|
||||||
end
|
|
||||||
return max
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function NagView:get_line_height()
|
function NagView:get_line_text_y_offset()
|
||||||
return self.max_lh + 2 * BORDER_WIDTH + 2 * style.padding.y
|
local lh = self:get_line_height()
|
||||||
|
local th = style.font:get_height()
|
||||||
|
return (lh - th) / 2
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Buttons height without padding
|
||||||
|
function NagView:get_buttons_height()
|
||||||
|
local lh = style.font:get_height()
|
||||||
|
local bt_padding = lh / 2
|
||||||
|
return lh + 2 * BORDER_WIDTH + 2 * bt_padding
|
||||||
|
end
|
||||||
|
|
||||||
|
function NagView:get_target_height()
|
||||||
|
return self.target_height + 2 * style.padding.y
|
||||||
end
|
end
|
||||||
|
|
||||||
function NagView:update()
|
function NagView:update()
|
||||||
NagView.super.update(self)
|
NagView.super.update(self)
|
||||||
|
|
||||||
if core.active_view == self and self.title then
|
if core.active_view == self and self.title then
|
||||||
self:move_towards(self.size, "y", self:get_line_height())
|
self:move_towards(self.size, "y", self:get_target_height())
|
||||||
self:move_towards(self, "underline_progress", 1)
|
self:move_towards(self, "underline_progress", 1)
|
||||||
else
|
else
|
||||||
self:move_towards(self.size, "y", 0)
|
self:move_towards(self.size, "y", 0)
|
||||||
|
@ -68,10 +78,10 @@ function NagView:each_option()
|
||||||
return coroutine.wrap(function()
|
return coroutine.wrap(function()
|
||||||
if not self.options then return end
|
if not self.options then return end
|
||||||
local opt, bw,bh,ox,oy
|
local opt, bw,bh,ox,oy
|
||||||
bh = self.max_lh + 2 * BORDER_WIDTH + style.padding.y
|
bh = self:get_buttons_height()
|
||||||
ox,oy = self:get_content_offset()
|
ox,oy = self:get_content_offset()
|
||||||
ox = ox + self.size.x
|
ox = ox + self.size.x
|
||||||
oy = oy + (self.size.y / 2) - (bh / 2)
|
oy = oy + self.size.y - bh - style.padding.y
|
||||||
|
|
||||||
for i = #self.options, 1, -1 do
|
for i = #self.options, 1, -1 do
|
||||||
opt = self.options[i]
|
opt = self.options[i]
|
||||||
|
@ -112,6 +122,7 @@ function NagView:on_text_input(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function NagView:draw()
|
function NagView:draw()
|
||||||
if self.size.y <= 0 or not self.title then return end
|
if self.size.y <= 0 or not self.title then return end
|
||||||
|
|
||||||
|
@ -129,7 +140,13 @@ function NagView:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- draw message
|
-- draw message
|
||||||
common.draw_text(style.font, style.nagbar_text, self.message, "left", ox, oy, self.size.x, self.size.y)
|
local lh = style.font:get_height() * config.line_height
|
||||||
|
oy = oy + style.padding.y + (self.target_height - self:get_message_height()) / 2
|
||||||
|
for msg_line in self.message:gmatch("(.-)\n") do
|
||||||
|
local ty = oy + self:get_line_text_y_offset()
|
||||||
|
renderer.draw_text(style.font, msg_line, ox, ty, style.nagbar_text)
|
||||||
|
oy = oy + lh
|
||||||
|
end
|
||||||
|
|
||||||
-- draw buttons
|
-- draw buttons
|
||||||
for i, opt, bx,by,bw,bh in self:each_option() do
|
for i, opt, bx,by,bw,bh in self:each_option() do
|
||||||
|
@ -159,14 +176,26 @@ local function findindex(tbl, prop)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function NagView:get_message_height()
|
||||||
|
local h = 0
|
||||||
|
for str in string.gmatch(self.message, "(.-)\n") do
|
||||||
|
h = h + style.font:get_height() * config.line_height
|
||||||
|
end
|
||||||
|
return h
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function NagView:next()
|
function NagView:next()
|
||||||
local opts = table.remove(self.queue, 1) or {}
|
local opts = table.remove(self.queue, 1) or {}
|
||||||
self.title = opts.title
|
self.title = opts.title
|
||||||
self.message = opts.message
|
self.message = opts.message and opts.message .. "\n"
|
||||||
self.options = opts.options
|
self.options = opts.options
|
||||||
self.on_selected = opts.on_selected
|
self.on_selected = opts.on_selected
|
||||||
if self.message and self.options then
|
if self.message and self.options then
|
||||||
self.max_lh = math.max(style.font:get_height(self.message), self:get_options_line_height())
|
local message_height = self:get_message_height()
|
||||||
|
-- self.target_height is the nagview height needed to display the message and
|
||||||
|
-- the buttons, excluding the top and bottom padding space.
|
||||||
|
self.target_height = math.max(message_height, self:get_buttons_height())
|
||||||
self:change_hovered(findindex(self.options, "default_yes"))
|
self:change_hovered(findindex(self.options, "default_yes"))
|
||||||
end
|
end
|
||||||
self.force_focus = self.message ~= nil
|
self.force_focus = self.message ~= nil
|
||||||
|
|
Loading…
Reference in New Issue