Add option to move mpv OSD to fix chat overlap issue
This commit is contained in:
parent
b239905d06
commit
6adf2ddd1b
@ -35,12 +35,12 @@ local assdraw = require "mp.assdraw"
|
|||||||
local opt = require 'mp.options'
|
local opt = require 'mp.options'
|
||||||
|
|
||||||
function format_scrolling(xpos, ypos, text)
|
function format_scrolling(xpos, ypos, text)
|
||||||
local chat_message = chat_format .. "{\\pos("..xpos..","..ypos..")}"..text.."\n"
|
local chat_message = "\n"..chat_format .. "{\\pos("..xpos..","..ypos..")}"..text.."\\N\\n"
|
||||||
return string.format(chat_message)
|
return string.format(chat_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
function format_chatroom(text)
|
function format_chatroom(text)
|
||||||
local chat_message = chat_format .. text.."\n"
|
local chat_message = chat_format .. text .."\\N\\n"
|
||||||
return string.format(chat_message)
|
return string.format(chat_message)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -116,16 +116,19 @@ function chat_update()
|
|||||||
chat_ass = chat_ass .. to_add
|
chat_ass = chat_ass .. to_add
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local xpos = opts['chatLeftMargin']
|
||||||
|
local ypos = opts['chatTopMargin']
|
||||||
|
chat_ass = "\n".."{\\pos("..xpos..","..ypos..")}".. chat_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 = assdraw.ass_new()
|
||||||
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:append(alphawarning_ass)
|
ass:append(alphawarning_ass)
|
||||||
else
|
else
|
||||||
|
|
||||||
ass:append(chat_ass)
|
|
||||||
ass:append(input_ass())
|
ass:append(input_ass())
|
||||||
|
ass:append(chat_ass)
|
||||||
end
|
end
|
||||||
mp.set_osd_ass(CANVAS_WIDTH,CANVAS_HEIGHT, ass.text)
|
mp.set_osd_ass(CANVAS_WIDTH,CANVAS_HEIGHT, ass.text)
|
||||||
end
|
end
|
||||||
@ -377,7 +380,7 @@ function ass_escape(str)
|
|||||||
str = str:gsub('}', '\\}')
|
str = str:gsub('}', '\\}')
|
||||||
-- Precede newlines with a ZWNBSP to prevent ASS's weird collapsing of
|
-- Precede newlines with a ZWNBSP to prevent ASS's weird collapsing of
|
||||||
-- consecutive newlines
|
-- consecutive newlines
|
||||||
str = str:gsub('\n', '\239\187\191\\N')
|
str = str:gsub('\n', '\239\187\191\n')
|
||||||
return str
|
return str
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -438,14 +441,14 @@ function input_ass()
|
|||||||
if opts['chatDirectInput'] then
|
if opts['chatDirectInput'] then
|
||||||
osd_help_message = opts['mpv-key-tab-hint'] .. " " .. osd_help_message
|
osd_help_message = opts['mpv-key-tab-hint'] .. " " .. osd_help_message
|
||||||
end
|
end
|
||||||
local help_prompt = '\n{\\an'..alignment..'\\pos('..secondary_pos..')\\fn' .. opts['chatOutputFontFamily'] .. '\\fs' .. (opts['chatInputFontSize']/1.25) .. '\\1c&H'..HINT_TEXT_COLOUR..'}' .. osd_help_message
|
local help_prompt = '\\N\\n{\\an'..alignment..'\\pos('..secondary_pos..')\\fn' .. opts['chatOutputFontFamily'] .. '\\fs' .. (opts['chatInputFontSize']/1.25) .. '\\1c&H'..HINT_TEXT_COLOUR..'}' .. osd_help_message
|
||||||
|
|
||||||
local firststyle = "{\\an"..alignment.."}{\\pos("..position..")}"
|
local firststyle = "{\\an"..alignment.."}{\\pos("..position..")}"
|
||||||
if opts['chatOutputEnabled'] and opts['chatOutputMode'] == CHAT_MODE_CHATROOM and opts['chatInputPosition'] == "Top" then
|
if opts['chatOutputEnabled'] and opts['chatOutputMode'] == CHAT_MODE_CHATROOM and opts['chatInputPosition'] == "Top" then
|
||||||
firststyle = get_output_style().."{'\\1c&H'"..fontColor.."}"
|
firststyle = get_output_style().."{'\\1c&H'"..fontColor.."}"
|
||||||
before_cur = before_cur .. firststyle
|
before_cur = before_cur .. firststyle
|
||||||
after_cur = after_cur .. firststyle
|
after_cur = after_cur .. firststyle
|
||||||
help_prompt = '\n'..firststyle..'{\\1c&H'..HINT_TEXT_COLOUR..'}' .. osd_help_message .. '\n'
|
help_prompt = '\\N\\n'..firststyle..'{\\1c&H'..HINT_TEXT_COLOUR..'}' .. osd_help_message .. '\\N\\n'
|
||||||
end
|
end
|
||||||
if key_hints_enabled == false then help_prompt = "" end
|
if key_hints_enabled == false then help_prompt = "" end
|
||||||
|
|
||||||
|
|||||||
@ -277,13 +277,9 @@ class NewMpvPlayer(OldMpvPlayer):
|
|||||||
self._listener.setReadyToSend(True)
|
self._listener.setReadyToSend(True)
|
||||||
|
|
||||||
def _setOSDPosition(self):
|
def _setOSDPosition(self):
|
||||||
if self._client._config['chatInputEnabled'] and self._client._config['chatOutputEnabled']:
|
if self._client._config['chatMoveOSD'] and (self._client._config['chatOutputEnabled'] or (self._client._config['chatInputEnabled'] and self._client._config['chatInputPosition'] == constants.INPUT_POSITION_TOP)):
|
||||||
if self._client._config['chatInputPosition'] == constants.INPUT_POSITION_BOTTOM:
|
|
||||||
self._setProperty("osd-align-y", "center")
|
|
||||||
else:
|
|
||||||
self._setProperty("osd-align-y", "bottom")
|
|
||||||
elif self._client._config['chatOutputEnabled']:
|
|
||||||
self._setProperty("osd-align-y", "bottom")
|
self._setProperty("osd-align-y", "bottom")
|
||||||
|
self._setProperty("osd-margin-y", int(self._client._config['chatOSDMargin']))
|
||||||
|
|
||||||
def _recentlyReset(self):
|
def _recentlyReset(self):
|
||||||
if not self.lastResetTime:
|
if not self.lastResetTime:
|
||||||
|
|||||||
@ -83,6 +83,8 @@ class ConfigurationGetter(object):
|
|||||||
"chatTopMargin": 25,
|
"chatTopMargin": 25,
|
||||||
"chatLeftMargin": 20,
|
"chatLeftMargin": 20,
|
||||||
"chatBottomMargin": 30,
|
"chatBottomMargin": 30,
|
||||||
|
"chatMoveOSD": True,
|
||||||
|
"chatOSDMargin": 60,
|
||||||
"notificationTimeout": 3,
|
"notificationTimeout": 3,
|
||||||
"alertTimeout": 5,
|
"alertTimeout": 5,
|
||||||
"chatTimeout": 7,
|
"chatTimeout": 7,
|
||||||
@ -132,6 +134,7 @@ class ConfigurationGetter(object):
|
|||||||
"chatInputEnabled",
|
"chatInputEnabled",
|
||||||
"chatInputFontUnderline",
|
"chatInputFontUnderline",
|
||||||
"chatDirectInput",
|
"chatDirectInput",
|
||||||
|
"chatMoveOSD",
|
||||||
"chatOutputEnabled",
|
"chatOutputEnabled",
|
||||||
"chatOutputFontUnderline"
|
"chatOutputFontUnderline"
|
||||||
]
|
]
|
||||||
@ -160,6 +163,7 @@ class ConfigurationGetter(object):
|
|||||||
"chatTopMargin",
|
"chatTopMargin",
|
||||||
"chatLeftMargin",
|
"chatLeftMargin",
|
||||||
"chatBottomMargin",
|
"chatBottomMargin",
|
||||||
|
"chatOSDMargin",
|
||||||
"notificationTimeout",
|
"notificationTimeout",
|
||||||
"alertTimeout",
|
"alertTimeout",
|
||||||
"chatTimeout"
|
"chatTimeout"
|
||||||
@ -195,6 +199,7 @@ class ConfigurationGetter(object):
|
|||||||
"chatOutputMode", "chatMaxLines",
|
"chatOutputMode", "chatMaxLines",
|
||||||
"chatTopMargin", "chatLeftMargin",
|
"chatTopMargin", "chatLeftMargin",
|
||||||
"chatBottomMargin", "chatDirectInput",
|
"chatBottomMargin", "chatDirectInput",
|
||||||
|
"chatMoveOSD", "chatOSDMargin",
|
||||||
"notificationTimeout", "alertTimeout",
|
"notificationTimeout", "alertTimeout",
|
||||||
"chatTimeout","chatOutputEnabled"],
|
"chatTimeout","chatOutputEnabled"],
|
||||||
"general": ["language", "checkForUpdatesAutomatically",
|
"general": ["language", "checkForUpdatesAutomatically",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user