From ade1d1f31962a5c978f119cbab14f367d00381c9 Mon Sep 17 00:00:00 2001 From: tomasklaen Date: Tue, 18 Jul 2023 18:21:00 +0200 Subject: [PATCH] feat: dropped compatibility for mpv 0.32 and below closes #359 --- README.md | 4 +-- script-opts/uosc.conf | 2 +- .../elements/BufferingIndicator.lua | 2 +- .../{uosc_shared => uosc}/elements/Button.lua | 2 +- .../elements/Controls.lua | 8 ++--- .../elements/Curtain.lua | 2 +- .../elements/CycleButton.lua | 2 +- .../elements/Element.lua | 0 .../elements/Elements.lua | 0 .../{uosc_shared => uosc}/elements/Menu.lua | 2 +- .../elements/PauseIndicator.lua | 2 +- .../{uosc_shared => uosc}/elements/Speed.lua | 2 +- .../elements/Timeline.lua | 2 +- .../{uosc_shared => uosc}/elements/TopBar.lua | 2 +- .../{uosc_shared => uosc}/elements/Volume.lua | 2 +- .../elements/WindowBorder.lua | 2 +- scripts/{uosc_shared => uosc}/intl/de.json | 0 scripts/{uosc_shared => uosc}/intl/es.json | 0 scripts/{uosc_shared => uosc}/intl/fr.json | 0 scripts/{uosc_shared => uosc}/intl/ro.json | 0 .../{uosc_shared => uosc}/intl/zh-hans.json | 0 scripts/{uosc_shared => uosc}/lib/ass.lua | 0 scripts/{uosc_shared => uosc}/lib/intl.lua | 2 +- scripts/{uosc_shared => uosc}/lib/menus.lua | 0 scripts/{uosc_shared => uosc}/lib/std.lua | 0 scripts/{uosc_shared => uosc}/lib/text.lua | 0 scripts/{uosc_shared => uosc}/lib/utils.lua | 0 scripts/{uosc.lua => uosc/main.lua} | 35 +++++++++---------- scripts/uosc_shared/main.lua | 5 --- 29 files changed, 35 insertions(+), 43 deletions(-) rename scripts/{uosc_shared => uosc}/elements/BufferingIndicator.lua (96%) rename scripts/{uosc_shared => uosc}/elements/Button.lua (98%) rename scripts/{uosc_shared => uosc}/elements/Controls.lua (98%) rename scripts/{uosc_shared => uosc}/elements/Curtain.lua (94%) rename scripts/{uosc_shared => uosc}/elements/CycleButton.lua (97%) rename scripts/{uosc_shared => uosc}/elements/Element.lua (100%) rename scripts/{uosc_shared => uosc}/elements/Elements.lua (100%) rename scripts/{uosc_shared => uosc}/elements/Menu.lua (99%) rename scripts/{uosc_shared => uosc}/elements/PauseIndicator.lua (97%) rename scripts/{uosc_shared => uosc}/elements/Speed.lua (99%) rename scripts/{uosc_shared => uosc}/elements/Timeline.lua (99%) rename scripts/{uosc_shared => uosc}/elements/TopBar.lua (99%) rename scripts/{uosc_shared => uosc}/elements/Volume.lua (99%) rename scripts/{uosc_shared => uosc}/elements/WindowBorder.lua (94%) rename scripts/{uosc_shared => uosc}/intl/de.json (100%) rename scripts/{uosc_shared => uosc}/intl/es.json (100%) rename scripts/{uosc_shared => uosc}/intl/fr.json (100%) rename scripts/{uosc_shared => uosc}/intl/ro.json (100%) rename scripts/{uosc_shared => uosc}/intl/zh-hans.json (100%) rename scripts/{uosc_shared => uosc}/lib/ass.lua (100%) rename scripts/{uosc_shared => uosc}/lib/intl.lua (97%) rename scripts/{uosc_shared => uosc}/lib/menus.lua (100%) rename scripts/{uosc_shared => uosc}/lib/std.lua (100%) rename scripts/{uosc_shared => uosc}/lib/text.lua (100%) rename scripts/{uosc_shared => uosc}/lib/utils.lua (100%) rename scripts/{uosc.lua => uosc/main.lua} (98%) delete mode 100644 scripts/uosc_shared/main.lua diff --git a/README.md b/README.md index 7f6654d..d329ced 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Most notable features: _List of all the possible places where it can be located is documented here: https://mpv.io/manual/master/#files_ - On Linux and macOS these terminal commands can be used to install or update uosc and thumbfast (if wget and unzip are installed): + On Linux and macOS these terminal commands can be used to install or update uosc (if wget and unzip are installed): ```sh mkdir -pv ~/.config/mpv/script-opts/ @@ -49,7 +49,7 @@ Most notable features: unzip -od ~/.config/mpv/ /tmp/uosc.zip rm -fv /tmp/uosc.zip ``` - + On Windows these equivalent PowerShell commands can be used: ```PowerShell New-Item -ItemType Directory -Force -Path "$env:APPDATA/mpv/script-opts/" diff --git a/script-opts/uosc.conf b/script-opts/uosc.conf index ab5df32..9e8c3e6 100644 --- a/script-opts/uosc.conf +++ b/script-opts/uosc.conf @@ -221,7 +221,7 @@ chapter_ranges=openings:30abf964,endings:30abf964,ads:c54e4e80 chapter_range_patterns=openings:オープニング;endings:エンディング # Localization language priority from highest to lowest. -# Built in languages can be found in `uosc_shared/intl`. +# Built in languages can be found in `uosc/intl`. # `slang` is a keyword to inherit values from `--slang` mpv config. # Supports paths to custom json files: `languages=~~/custom.json,slang,en` languages=slang,en diff --git a/scripts/uosc_shared/elements/BufferingIndicator.lua b/scripts/uosc/elements/BufferingIndicator.lua similarity index 96% rename from scripts/uosc_shared/elements/BufferingIndicator.lua rename to scripts/uosc/elements/BufferingIndicator.lua index e2aa071..8344774 100644 --- a/scripts/uosc_shared/elements/BufferingIndicator.lua +++ b/scripts/uosc/elements/BufferingIndicator.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') ---@class BufferingIndicator : Element local BufferingIndicator = class(Element) diff --git a/scripts/uosc_shared/elements/Button.lua b/scripts/uosc/elements/Button.lua similarity index 98% rename from scripts/uosc_shared/elements/Button.lua rename to scripts/uosc/elements/Button.lua index e57d614..ed06568 100644 --- a/scripts/uosc_shared/elements/Button.lua +++ b/scripts/uosc/elements/Button.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') ---@alias ButtonProps {icon: string; on_click: function; anchor_id?: string; active?: boolean; badge?: string|number; foreground?: string; background?: string; tooltip?: string} diff --git a/scripts/uosc_shared/elements/Controls.lua b/scripts/uosc/elements/Controls.lua similarity index 98% rename from scripts/uosc_shared/elements/Controls.lua rename to scripts/uosc/elements/Controls.lua index ea4ca34..1166e60 100644 --- a/scripts/uosc_shared/elements/Controls.lua +++ b/scripts/uosc/elements/Controls.lua @@ -1,7 +1,7 @@ -local Element = require('uosc_shared/elements/Element') -local Button = require('uosc_shared/elements/Button') -local CycleButton = require('uosc_shared/elements/CycleButton') -local Speed = require('uosc_shared/elements/Speed') +local Element = require('elements/Element') +local Button = require('elements/Button') +local CycleButton = require('elements/CycleButton') +local Speed = require('elements/Speed') -- `scale` - `options.controls_size` scale factor. -- `ratio` - Width/height ratio of a static or dynamic element. diff --git a/scripts/uosc_shared/elements/Curtain.lua b/scripts/uosc/elements/Curtain.lua similarity index 94% rename from scripts/uosc_shared/elements/Curtain.lua rename to scripts/uosc/elements/Curtain.lua index 99b9f14..f7ded63 100644 --- a/scripts/uosc_shared/elements/Curtain.lua +++ b/scripts/uosc/elements/Curtain.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') ---@class Curtain : Element local Curtain = class(Element) diff --git a/scripts/uosc_shared/elements/CycleButton.lua b/scripts/uosc/elements/CycleButton.lua similarity index 97% rename from scripts/uosc_shared/elements/CycleButton.lua rename to scripts/uosc/elements/CycleButton.lua index 7f1c02f..e3bb4a6 100644 --- a/scripts/uosc_shared/elements/CycleButton.lua +++ b/scripts/uosc/elements/CycleButton.lua @@ -1,4 +1,4 @@ -local Button = require('uosc_shared/elements/Button') +local Button = require('elements/Button') ---@alias CycleState {value: any; icon: string; active?: boolean} ---@alias CycleButtonProps {prop: string; states: CycleState[]; anchor_id?: string; tooltip?: string} diff --git a/scripts/uosc_shared/elements/Element.lua b/scripts/uosc/elements/Element.lua similarity index 100% rename from scripts/uosc_shared/elements/Element.lua rename to scripts/uosc/elements/Element.lua diff --git a/scripts/uosc_shared/elements/Elements.lua b/scripts/uosc/elements/Elements.lua similarity index 100% rename from scripts/uosc_shared/elements/Elements.lua rename to scripts/uosc/elements/Elements.lua diff --git a/scripts/uosc_shared/elements/Menu.lua b/scripts/uosc/elements/Menu.lua similarity index 99% rename from scripts/uosc_shared/elements/Menu.lua rename to scripts/uosc/elements/Menu.lua index 0d08ea7..76bbc7c 100644 --- a/scripts/uosc_shared/elements/Menu.lua +++ b/scripts/uosc/elements/Menu.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') -- Menu data structure accepted by `Menu:open(menu)`. ---@alias MenuData {type?: string; title?: string; hint?: string; keep_open?: boolean; separator?: boolean; items?: MenuDataItem[]; selected_index?: integer;} diff --git a/scripts/uosc_shared/elements/PauseIndicator.lua b/scripts/uosc/elements/PauseIndicator.lua similarity index 97% rename from scripts/uosc_shared/elements/PauseIndicator.lua rename to scripts/uosc/elements/PauseIndicator.lua index 82a7e43..3f7e021 100644 --- a/scripts/uosc_shared/elements/PauseIndicator.lua +++ b/scripts/uosc/elements/PauseIndicator.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') ---@class PauseIndicator : Element local PauseIndicator = class(Element) diff --git a/scripts/uosc_shared/elements/Speed.lua b/scripts/uosc/elements/Speed.lua similarity index 99% rename from scripts/uosc_shared/elements/Speed.lua rename to scripts/uosc/elements/Speed.lua index 6ea5097..bc4f440 100644 --- a/scripts/uosc_shared/elements/Speed.lua +++ b/scripts/uosc/elements/Speed.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') ---@alias Dragging { start_time: number; start_x: number; distance: number; speed_distance: number; start_speed: number; } diff --git a/scripts/uosc_shared/elements/Timeline.lua b/scripts/uosc/elements/Timeline.lua similarity index 99% rename from scripts/uosc_shared/elements/Timeline.lua rename to scripts/uosc/elements/Timeline.lua index 158267d..29708bf 100644 --- a/scripts/uosc_shared/elements/Timeline.lua +++ b/scripts/uosc/elements/Timeline.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') ---@class Timeline : Element local Timeline = class(Element) diff --git a/scripts/uosc_shared/elements/TopBar.lua b/scripts/uosc/elements/TopBar.lua similarity index 99% rename from scripts/uosc_shared/elements/TopBar.lua rename to scripts/uosc/elements/TopBar.lua index 0bb3e64..10cd2b7 100644 --- a/scripts/uosc_shared/elements/TopBar.lua +++ b/scripts/uosc/elements/TopBar.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') ---@alias TopBarButtonProps {icon: string; background: string; anchor_id?: string; command: string|fun()} diff --git a/scripts/uosc_shared/elements/Volume.lua b/scripts/uosc/elements/Volume.lua similarity index 99% rename from scripts/uosc_shared/elements/Volume.lua rename to scripts/uosc/elements/Volume.lua index 2f591b6..356feca 100644 --- a/scripts/uosc_shared/elements/Volume.lua +++ b/scripts/uosc/elements/Volume.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') --[[ MuteButton ]] diff --git a/scripts/uosc_shared/elements/WindowBorder.lua b/scripts/uosc/elements/WindowBorder.lua similarity index 94% rename from scripts/uosc_shared/elements/WindowBorder.lua rename to scripts/uosc/elements/WindowBorder.lua index c5544f5..d1a08d0 100644 --- a/scripts/uosc_shared/elements/WindowBorder.lua +++ b/scripts/uosc/elements/WindowBorder.lua @@ -1,4 +1,4 @@ -local Element = require('uosc_shared/elements/Element') +local Element = require('elements/Element') ---@class WindowBorder : Element local WindowBorder = class(Element) diff --git a/scripts/uosc_shared/intl/de.json b/scripts/uosc/intl/de.json similarity index 100% rename from scripts/uosc_shared/intl/de.json rename to scripts/uosc/intl/de.json diff --git a/scripts/uosc_shared/intl/es.json b/scripts/uosc/intl/es.json similarity index 100% rename from scripts/uosc_shared/intl/es.json rename to scripts/uosc/intl/es.json diff --git a/scripts/uosc_shared/intl/fr.json b/scripts/uosc/intl/fr.json similarity index 100% rename from scripts/uosc_shared/intl/fr.json rename to scripts/uosc/intl/fr.json diff --git a/scripts/uosc_shared/intl/ro.json b/scripts/uosc/intl/ro.json similarity index 100% rename from scripts/uosc_shared/intl/ro.json rename to scripts/uosc/intl/ro.json diff --git a/scripts/uosc_shared/intl/zh-hans.json b/scripts/uosc/intl/zh-hans.json similarity index 100% rename from scripts/uosc_shared/intl/zh-hans.json rename to scripts/uosc/intl/zh-hans.json diff --git a/scripts/uosc_shared/lib/ass.lua b/scripts/uosc/lib/ass.lua similarity index 100% rename from scripts/uosc_shared/lib/ass.lua rename to scripts/uosc/lib/ass.lua diff --git a/scripts/uosc_shared/lib/intl.lua b/scripts/uosc/lib/intl.lua similarity index 97% rename from scripts/uosc_shared/lib/intl.lua rename to scripts/uosc/lib/intl.lua index e3acecd..9018d81 100644 --- a/scripts/uosc_shared/lib/intl.lua +++ b/scripts/uosc/lib/intl.lua @@ -1,4 +1,4 @@ -local intl_dir = '~~/scripts/uosc_shared/intl/' +local intl_dir = '~~/scripts/uosc/intl/' local locale = {} local cache = {} diff --git a/scripts/uosc_shared/lib/menus.lua b/scripts/uosc/lib/menus.lua similarity index 100% rename from scripts/uosc_shared/lib/menus.lua rename to scripts/uosc/lib/menus.lua diff --git a/scripts/uosc_shared/lib/std.lua b/scripts/uosc/lib/std.lua similarity index 100% rename from scripts/uosc_shared/lib/std.lua rename to scripts/uosc/lib/std.lua diff --git a/scripts/uosc_shared/lib/text.lua b/scripts/uosc/lib/text.lua similarity index 100% rename from scripts/uosc_shared/lib/text.lua rename to scripts/uosc/lib/text.lua diff --git a/scripts/uosc_shared/lib/utils.lua b/scripts/uosc/lib/utils.lua similarity index 100% rename from scripts/uosc_shared/lib/utils.lua rename to scripts/uosc/lib/utils.lua diff --git a/scripts/uosc.lua b/scripts/uosc/main.lua similarity index 98% rename from scripts/uosc.lua rename to scripts/uosc/main.lua index 4fa7b80..0394e35 100644 --- a/scripts/uosc.lua +++ b/scripts/uosc/main.lua @@ -9,10 +9,7 @@ osd = mp.create_osd_overlay('ass-events') INFINITY = 1e309 QUARTER_PI_SIN = math.sin(math.pi / 4) --- Enables relative requires from `scripts` directory -package.path = package.path .. ';' .. mp.find_config_file('scripts') .. '/?.lua' - -require('uosc_shared/lib/std') +require('lib/std') --[[ OPTIONS ]] @@ -133,7 +130,7 @@ fg, bg = serialize_rgba(options.foreground).color, serialize_rgba(options.backgr fgt, bgt = serialize_rgba(options.foreground_text).color, serialize_rgba(options.background_text).color --[[ INTERNATIONALIZATION ]] -local intl = require('uosc_shared/lib/intl') +local intl = require('lib/intl') t = intl.t --[[ CONFIG ]] @@ -435,14 +432,14 @@ state = { thumbnail = {width = 0, height = 0, disabled = false} external = {} -- Properties set by external scripts key_binding_overwrites = {} -- Table of key_binding:mpv_command -Elements = require('uosc_shared/elements/Elements') -Menu = require('uosc_shared/elements/Menu') +Elements = require('elements/Elements') +Menu = require('elements/Menu') -- State dependent utilities -require('uosc_shared/lib/utils') -require('uosc_shared/lib/text') -require('uosc_shared/lib/ass') -require('uosc_shared/lib/menus') +require('lib/utils') +require('lib/text') +require('lib/ass') +require('lib/menus') --[[ STATE UPDATERS ]] @@ -1285,11 +1282,11 @@ mp.register_script_message('overwrite-binding', function(name, command) key_bind --[[ ELEMENTS ]] -require('uosc_shared/elements/WindowBorder'):new() -require('uosc_shared/elements/BufferingIndicator'):new() -require('uosc_shared/elements/PauseIndicator'):new() -require('uosc_shared/elements/TopBar'):new() -require('uosc_shared/elements/Timeline'):new() -if options.controls and options.controls ~= 'never' then require('uosc_shared/elements/Controls'):new() end -if itable_index_of({'left', 'right'}, options.volume) then require('uosc_shared/elements/Volume'):new() end -require('uosc_shared/elements/Curtain'):new() +require('elements/WindowBorder'):new() +require('elements/BufferingIndicator'):new() +require('elements/PauseIndicator'):new() +require('elements/TopBar'):new() +require('elements/Timeline'):new() +if options.controls and options.controls ~= 'never' then require('elements/Controls'):new() end +if itable_index_of({'left', 'right'}, options.volume) then require('elements/Volume'):new() end +require('elements/Curtain'):new() diff --git a/scripts/uosc_shared/main.lua b/scripts/uosc_shared/main.lua deleted file mode 100644 index 323027f..0000000 --- a/scripts/uosc_shared/main.lua +++ /dev/null @@ -1,5 +0,0 @@ ---[[ -File required for compatibility between mpv: -- 0.32 - doesn't support `dir/main.lua`, so we need `uosc.lua` in root -- 0.33 - requires `main.lua` in directories -]]