dyphire / mpv-scripts

userscripts for mpv
MIT License
53 stars 5 forks source link

[Feature Request] chapter-list.lua Auto Hide and chapter-list.conf #6

Closed BhaturaGuy closed 1 year ago

BhaturaGuy commented 1 year ago

Auto hide chapter list after x seconds of inactivity just like mpv's default chapter list. chapter-list.conf to change font size, color, alignment, etc. Just like https://github.com/Eisa01/mpv-scripts/blob/master/script-opts/SimpleHistory.conf

dyphire commented 1 year ago

Auto hide chapter list after x seconds of inactivity just like mpv's default chapter list.

This script implements the menu function by scroll-list. Unfortunately, it does not provide the function of auto hide after timeout. So this cannot be achieved at present.

chapter-list.conf to change font size, color, alignment, etc. Just like https://github.com/Eisa01/mpv-scripts/blob/master/script-opts/SimpleHistory.conf

Implemented it in this commit: https://github.com/dyphire/mpv-scripts/commit/a2515456c2d798a9aac530ae4d564d398e34fe4e

BhaturaGuy commented 1 year ago

Did I do something wrong? This is my chapter-list.conf

header="Chapter List [%cursor%/%total%]\\N ————————————————————————"
header_style=[[{\q2\fs25\c&00ccff&}]]
list_style=[[{\q2\fs20\c&Hffffff&}]]
wrapper_style=[[{\c&00ccff&\fs16}]]
cursor_style=[[{\c&00ccff&}]]
selected_style=[[{\c&Hfce788&}]]
cursor=[[●\h\h\h\h]]
indent=[[○\h\h\h\h]]
num_entries=17
wrap=yes
reset_cursor_on_close=yes

But chapter-list.lua is still displaying in default format. Screenshot (7)

It should display it like this: Screenshot (8)

Also if possible I want to display indent and cursor after the chapter timestamp just like mpv's default chapter list. Screenshot (9)

dyphire commented 1 year ago

Did I do something wrong? This is my chapter-list.conf

header="Chapter List [%cursor%/%total%]\\N ————————————————————————"
header_style=[[{\q2\fs25\c&00ccff&}]]
list_style=[[{\q2\fs20\c&Hffffff&}]]
wrapper_style=[[{\c&00ccff&\fs16}]]
cursor_style=[[{\c&00ccff&}]]
selected_style=[[{\c&Hfce788&}]]
cursor=[[●\h\h\h\h]]
indent=[[○\h\h\h\h]]
num_entries=17
wrap=yes
reset_cursor_on_close=yes

You should know more about the syntax of the configuration files of mpv scripts, which will be very helpful. It should be chapter_list.conf. It is generally unnecessary to use the symbols of " and [[]] in the script configuration file.

header=Chapter List [%cursor%/%total%]\\N ————————————————————————
header_style={\q2\fs25\c&00ccff&}
list_style={\q2\fs20\c&Hffffff&}
wrapper_style={\c&00ccff&\fs16}
cursor_style={\c&00ccff&}
selected_style={\c&Hfce788&}
cursor=●\h\h\h\h
indent=○\h\h\h\h
num_entries=17
wrap=yes
reset_cursor_on_close=yes

Also if possible I want to display indent and cursor after the chapter timestamp just like mpv's default chapter list.

I'm not interested in this, but you can implement it through the following patch

---
 chapter-list.lua | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/chapter-list.lua b/chapter-list.lua
index 0b1b606..4d2940b 100644
--- a/chapter-list.lua
+++ b/chapter-list.lua
@@ -79,10 +79,6 @@ function chapter_list(curr_chapter)
     local chapter_list = mp.get_property_native('chapter-list', {})
     for i = 1, #chapter_list do
         local item = {}
-        if (i - 1 == curr_chapter) then
-            list.selected = curr_chapter + 1
-            item.style = o.active_style
-        end

         local time = chapter_list[i].time
         local title = chapter_list[i].title
@@ -93,7 +89,13 @@ function chapter_list(curr_chapter)
         if time < 0 then time = 0
         else time = math.floor(time) end
         item.ass = string.format("[%02d:%02d:%02d]", math.floor(time / 60 / 60), math.floor(time / 60) % 60, time % 60)
-        item.ass = item.ass .. '\\h\\h\\h' .. list.ass_escape(title)
+        if (i - 1 == curr_chapter) then
+            list.selected = curr_chapter + 1
+            item.style = o.active_style
+            item.ass = item.ass .. '\\h\\h●\\h\\h' .. list.ass_escape(title)
+        else
+            item.ass = item.ass .. '\\h\\h○\\h\\h' .. list.ass_escape(title)
+        end
         list.list[i] = item
     end
     list:update()
--