Use mpv's new create_osd_overlay API
The internal and previously used set_osd_ass API has been deprecated.
This commit is contained in:
parent
2d6d4b43ce
commit
6319fc5bb4
@ -50,7 +50,6 @@ local FONT_SIZE_MULTIPLIER = 2
|
|||||||
|
|
||||||
local chat_log = {}
|
local chat_log = {}
|
||||||
|
|
||||||
local assdraw = require "mp.assdraw"
|
|
||||||
|
|
||||||
local opt = require 'mp.options'
|
local opt = require 'mp.options'
|
||||||
|
|
||||||
@ -94,6 +93,10 @@ function clear_chat()
|
|||||||
chat_log = {}
|
chat_log = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local osd_overlay = mp.create_osd_overlay("ass-events")
|
||||||
|
osd_overlay.res_x = CANVAS_WIDTH
|
||||||
|
osd_overlay.res_y = CANVAS_HEIGHT
|
||||||
|
|
||||||
local alert_osd = ""
|
local alert_osd = ""
|
||||||
local last_alert_osd_time = nil
|
local last_alert_osd_time = nil
|
||||||
local alert_osd_mood = MOOD_NEUTRAL
|
local alert_osd_mood = MOOD_NEUTRAL
|
||||||
@ -133,9 +136,7 @@ function add_chat(chat_message, mood)
|
|||||||
chat_log[entry] = { xpos=CANVAS_WIDTH, timecreated=mp.get_time(), text=tostring(chat_message), row=row }
|
chat_log[entry] = { xpos=CANVAS_WIDTH, timecreated=mp.get_time(), text=tostring(chat_message), row=row }
|
||||||
end
|
end
|
||||||
|
|
||||||
local old_ass_text = ''
|
|
||||||
function chat_update()
|
function chat_update()
|
||||||
local ass = assdraw.ass_new()
|
|
||||||
local chat_ass = ''
|
local chat_ass = ''
|
||||||
local rowsAdded = 0
|
local rowsAdded = 0
|
||||||
local to_add = ''
|
local to_add = ''
|
||||||
@ -169,25 +170,23 @@ function chat_update()
|
|||||||
local ypos = opts['chatTopMargin']
|
local ypos = opts['chatTopMargin']
|
||||||
chat_ass = "\n".."{\\pos("..xpos..","..ypos..")}".. chat_ass
|
chat_ass = "\n".."{\\pos("..xpos..","..ypos..")}".. chat_ass
|
||||||
|
|
||||||
|
local ass = ''
|
||||||
if use_alpha_rows_for_chat == false and opts['chatDirectInput'] == true then
|
if use_alpha_rows_for_chat == false and opts['chatDirectInput'] == true then
|
||||||
local alphawarning_ass = assdraw.ass_new()
|
local alphawarning_ass = "{\\a6}{\\1c&H"..ALPHA_WARNING_TEXT_COLOUR.."}"..opts['alphakey-mode-warning-first-line'].."\n{\\a6}{\\1c&H"..ALPHA_WARNING_TEXT_COLOUR.."}"..opts['alphakey-mode-warning-second-line']
|
||||||
alphawarning_ass = "{\\a6}{\\1c&H"..ALPHA_WARNING_TEXT_COLOUR.."}"..opts['alphakey-mode-warning-first-line'].."\n{\\a6}{\\1c&H"..ALPHA_WARNING_TEXT_COLOUR.."}"..opts['alphakey-mode-warning-second-line']
|
ass = alphawarning_ass
|
||||||
ass:append(alphawarning_ass)
|
|
||||||
elseif opts['chatOutputMode'] == CHAT_MODE_CHATROOM and opts['chatInputPosition'] == "Top" then
|
elseif opts['chatOutputMode'] == CHAT_MODE_CHATROOM and opts['chatInputPosition'] == "Top" then
|
||||||
ass:append(chat_ass)
|
ass = chat_ass .. input_ass()
|
||||||
ass:append(input_ass())
|
|
||||||
else
|
else
|
||||||
ass:append(input_ass())
|
ass = input_ass() .. chat_ass
|
||||||
ass:append(chat_ass)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- The commit that introduced the new API removed the internal heuristics on whether a refresh is required,
|
-- The commit that introduced the new API removed the internal heuristics on whether a refresh is required,
|
||||||
-- so we check for changed text manually to not cause excessive GPU load
|
-- so we check for changed text manually to not cause excessive GPU load
|
||||||
-- https://github.com/mpv-player/mpv/commit/07287262513c0d1ea46b7beaf100e73f2008295f#diff-d88d582039dea993b6229da9f61ba76cL530
|
-- https://github.com/mpv-player/mpv/commit/07287262513c0d1ea46b7beaf100e73f2008295f#diff-d88d582039dea993b6229da9f61ba76cL530
|
||||||
if ass.text ~= old_ass_text then
|
if ass ~= osd_overlay.data then
|
||||||
mp.set_osd_ass(CANVAS_WIDTH,CANVAS_HEIGHT, ass.text)
|
osd_overlay.data = ass
|
||||||
old_ass_text = ass.text
|
osd_overlay:update()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function process_alert_osd()
|
function process_alert_osd()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user