| @@ -280,7 +280,7 @@ function get_slider_value(element) · 279 unmodified lines |
| 280 | 280 | end |
| 281 | 281 | |
| 282 | 282 | function countone(val) |
| 283 | | − if not (user_opts.iamaprogrammer) then |
| 283 | + if not user_opts.iamaprogrammer then |
| 284 | 284 | val = val + 1 |
| 285 | 285 | end |
| 286 | 286 | return val |
| @@ -301,7 +301,7 @@ end · 14 unmodified lines |
| 301 | 301 | |
| 302 | 302 | function add_area(name, x1, y1, x2, y2) |
| 303 | 303 | -- create area if needed |
| 304 | | − if (osc_param.areas[name] == nil) then |
| 304 | + if osc_param.areas[name] == nil then |
| 305 | 305 | osc_param.areas[name] = {} |
| 306 | 306 | end |
| 307 | 307 | table.insert(osc_param.areas[name], {x1=x1, y1=y1, x2=x2, y2=y2}) |
| @@ -356,7 +356,7 @@ function update_tracklist() · 48 unmodified lines |
| 356 | 356 | tracks_mpv = {} |
| 357 | 357 | tracks_mpv.video, tracks_mpv.audio, tracks_mpv.sub = {}, {}, {} |
| 358 | 358 | for n = 1, #tracktable do |
| 359 | | − if not (tracktable[n].type == "unknown") then |
| 359 | + if tracktable[n].type ~= "unknown" then |
| 360 | 360 | local type = tracktable[n].type |
| 361 | 361 | local mpv_id = tonumber(tracktable[n].id) |
| 362 | 362 | |
| @@ -379,9 +379,9 @@ function get_tracklist(type) · 16 unmodified lines |
| 379 | 379 | for n = 1, #tracks_osc[type] do |
| 380 | 380 | local track = tracks_osc[type][n] |
| 381 | 381 | local lang, title, selected = "unknown", "", "○" |
| 382 | | − if not(track.lang == nil) then lang = track.lang end |
| 383 | | − if not(track.title == nil) then title = track.title end |
| 384 | | − if (track.id == tonumber(mp.get_property(type))) then |
| 382 | + if track.lang ~= nil then lang = track.lang end |
| 383 | + if track.title ~= nil then title = track.title end |
| 384 | + if track.id == tonumber(mp.get_property(type)) then |
| 385 | 385 | selected = "●" |
| 386 | 386 | end |
| 387 | 387 | msg = msg.."\n"..selected.." "..n..": ["..lang.."] "..title |
| @@ -394,7 +394,7 @@ end · 6 unmodified lines |
| 394 | 394 | --(+1 -> next, -1 -> previous) |
| 395 | 395 | function set_track(type, next) |
| 396 | 396 | local current_track_mpv, current_track_osc |
| 397 | | − if (mp.get_property(type) == "no") then |
| 397 | + if mp.get_property(type) == "no" then |
| 398 | 398 | current_track_osc = 0 |
| 399 | 399 | else |
| 400 | 400 | current_track_mpv = tonumber(mp.get_property(type)) |
| @@ -410,7 +410,7 @@ function set_track(type, next) · 9 unmodified lines |
| 410 | 410 | |
| 411 | 411 | mp.commandv("set", type, new_track_mpv) |
| 412 | 412 | |
| 413 | | − if (new_track_osc == 0) then |
| 413 | + if new_track_osc == 0 then |
| 414 | 414 | show_message(nicetypes[type] .. " Track: none") |
| 415 | 415 | else |
| 416 | 416 | show_message(nicetypes[type] .. " Track: " |
| @@ -457,7 +457,7 @@ function prepare_elements() · 40 unmodified lines |
| 457 | 457 | -- remove elements without layout or invisible |
| 458 | 458 | local elements2 = {} |
| 459 | 459 | for n, element in pairs(elements) do |
| 460 | | − if not (element.layout == nil) and (element.visible) then |
| 460 | + if element.layout ~= nil and element.visible then |
| 461 | 461 | table.insert(elements2, element) |
| 462 | 462 | end |
| 463 | 463 | end |
| @@ -492,14 +492,14 @@ function prepare_elements() · 28 unmodified lines |
| 492 | 492 | local static_ass = assdraw.ass_new() |
| 493 | 493 | |
| 494 | 494 | |
| 495 | | − if (element.type == "box") then |
| 495 | + if element.type == "box" then |
| 496 | 496 | --draw box |
| 497 | 497 | static_ass:draw_start() |
| 498 | 498 | ass_draw_rr_h_cw(static_ass, 0, 0, elem_geo.w, elem_geo.h, |
| 499 | 499 | element.layout.box.radius, element.layout.box.hexagon) |
| 500 | 500 | static_ass:draw_stop() |
| 501 | 501 | |
| 502 | | − elseif (element.type == "slider") then |
| 502 | + elseif element.type == "slider" then |
| 503 | 503 | --draw static slider parts |
| 504 | 504 | |
| 505 | 505 | local r1 = 0 |
| @@ -509,13 +509,13 @@ function prepare_elements() · 3 unmodified lines |
| 509 | 509 | local foV = slider_lo.border + slider_lo.gap |
| 510 | 510 | |
| 511 | 511 | -- calculate positions of min and max points |
| 512 | | − if (slider_lo.stype ~= "bar") then |
| 512 | + if slider_lo.stype ~= "bar" then |
| 513 | 513 | r1 = elem_geo.h / 2 |
| 514 | 514 | element.slider.min.ele_pos = elem_geo.h / 2 |
| 515 | 515 | element.slider.max.ele_pos = elem_geo.w - (elem_geo.h / 2) |
| 516 | | − if (slider_lo.stype == "diamond") then |
| 516 | + if slider_lo.stype == "diamond" then |
| 517 | 517 | r2 = (elem_geo.h - 2 * slider_lo.border) / 2 |
| 518 | | − elseif (slider_lo.stype == "knob") then |
| 518 | + elseif slider_lo.stype == "knob" then |
| 519 | 519 | r2 = r1 |
| 520 | 520 | end |
| 521 | 521 | else |
| @@ -543,45 +543,45 @@ function prepare_elements() · 21 unmodified lines |
| 543 | 543 | r2, slider_lo.stype == "diamond") |
| 544 | 544 | |
| 545 | 545 | -- marker nibbles |
| 546 | | − if not (element.slider.markerF == nil) and (slider_lo.gap > 0) then |
| 546 | + if element.slider.markerF ~= nil and slider_lo.gap > 0 then |
| 547 | 547 | local markers = element.slider.markerF() |
| 548 | 548 | for _,marker in pairs(markers) do |
| 549 | | − if (marker > element.slider.min.value) and |
| 550 | | − (marker < element.slider.max.value) then |
| 549 | + if marker > element.slider.min.value and |
| 550 | + marker < element.slider.max.value then |
| 551 | 551 | |
| 552 | 552 | local s = get_slider_ele_pos_for(element, marker) |
| 553 | 553 | |
| 554 | | − if (slider_lo.gap > 1) then -- draw triangles |
| 554 | + if slider_lo.gap > 1 then -- draw triangles |
| 555 | 555 | |
| 556 | 556 | local a = slider_lo.gap / 0.5 --0.866 |
| 557 | 557 | |
| 558 | 558 | --top |
| 559 | | − if (slider_lo.nibbles_top) then |
| 560 | | − static_ass:move_to(s - (a/2), slider_lo.border) |
| 561 | | − static_ass:line_to(s + (a/2), slider_lo.border) |
| 559 | + if slider_lo.nibbles_top then |
| 560 | + static_ass:move_to(s - (a / 2), slider_lo.border) |
| 561 | + static_ass:line_to(s + (a / 2), slider_lo.border) |
| 562 | 562 | static_ass:line_to(s, foV) |
| 563 | 563 | end |
| 564 | 564 | |
| 565 | 565 | --bottom |
| 566 | | − if (slider_lo.nibbles_bottom) then |
| 567 | | − static_ass:move_to(s - (a/2), |
| 566 | + if slider_lo.nibbles_bottom then |
| 567 | + static_ass:move_to(s - (a / 2), |
| 568 | 568 | elem_geo.h - slider_lo.border) |
| 569 | 569 | static_ass:line_to(s, |
| 570 | 570 | elem_geo.h - foV) |
| 571 | | − static_ass:line_to(s + (a/2), |
| 571 | + static_ass:line_to(s + (a / 2), |
| 572 | 572 | elem_geo.h - slider_lo.border) |
| 573 | 573 | end |
| 574 | 574 | |
| 575 | 575 | else -- draw 2x1px nibbles |
| 576 | 576 | |
| 577 | 577 | --top |
| 578 | | − if (slider_lo.nibbles_top) then |
| 578 | + if slider_lo.nibbles_top then |
| 579 | 579 | static_ass:rect_cw(s - 1, slider_lo.border, |
| 580 | 580 | s + 1, slider_lo.border + slider_lo.gap); |
| 581 | 581 | end |
| 582 | 582 | |
| 583 | 583 | --bottom |
| 584 | | − if (slider_lo.nibbles_bottom) then |
| 584 | + if slider_lo.nibbles_bottom then |
| 585 | 585 | static_ass:rect_cw(s - 1, |
| 586 | 586 | elem_geo.h -slider_lo.border -slider_lo.gap, |
| 587 | 587 | s + 1, elem_geo.h - slider_lo.border); |
| @@ -597,7 +597,7 @@ function prepare_elements() · 9 unmodified lines |
| 597 | 597 | |
| 598 | 598 | -- if the element is supposed to be disabled, |
| 599 | 599 | -- style it accordingly and kill the eventresponders |
| 600 | | − if not (element.enabled) then |
| 600 | + if not element.enabled then |
| 601 | 601 | element.layout.alpha[1] = 136 |
| 602 | 602 | element.eventresponder = nil |
| 603 | 603 | end |
| @@ -648,18 +648,18 @@ function render_elements(master_ass) · 44 unmodified lines |
| 648 | 648 | if element.eventresponder and (state.active_element == n) then |
| 649 | 649 | |
| 650 | 650 | -- run render event functions |
| 651 | | − if not (element.eventresponder.render == nil) then |
| 651 | + if element.eventresponder.render ~= nil then |
| 652 | 652 | element.eventresponder.render(element) |
| 653 | 653 | end |
| 654 | 654 | |
| 655 | 655 | if mouse_hit(element) then |
| 656 | 656 | -- mouse down styling |
| 657 | | − if (element.styledown) then |
| 657 | + if element.styledown then |
| 658 | 658 | style_ass:append(osc_styles.elementDown) |
| 659 | 659 | end |
| 660 | 660 | |
| 661 | | − if (element.softrepeat) and (state.mouse_down_counter >= 15 |
| 662 | | − and state.mouse_down_counter % 5 == 0) then |
| 661 | + if element.softrepeat and state.mouse_down_counter >= 15 |
| 662 | + and state.mouse_down_counter % 5 == 0 then |
| 663 | 663 | |
| 664 | 664 | element.eventresponder[state.active_event_source.."_down"](element) |
| 665 | 665 | end |
| @@ -672,11 +672,11 @@ function render_elements(master_ass) · 6 unmodified lines |
| 672 | 672 | |
| 673 | 673 | elem_ass:merge(style_ass) |
| 674 | 674 | |
| 675 | | − if not (element.type == "button") then |
| 675 | + if element.type ~= "button" then |
| 676 | 676 | elem_ass:merge(element.static_ass) |
| 677 | 677 | end |
| 678 | 678 | |
| 679 | | − if (element.type == "slider") then |
| 679 | + if element.type == "slider" then |
| 680 | 680 | |
| 681 | 681 | local slider_lo = element.layout.slider |
| 682 | 682 | local elem_geo = element.layout.geometry |
| @@ -794,8 +794,7 @@ function render_elements(master_ass) · 111 unmodified lines |
| 794 | 794 | elem_ass:draw_stop() |
| 795 | 795 | |
| 796 | 796 | -- add tooltip |
| 797 | | − if not (element.slider.tooltipF == nil) then |
| 798 | | − |
| 797 | + if element.slider.tooltipF ~= nil then |
| 799 | 798 | if mouse_hit(element) then |
| 800 | 799 | local sliderpos = get_slider_value(element) |
| 801 | 800 | local tooltiplabel = element.slider.tooltipF(sliderpos) |
| @@ -804,21 +803,21 @@ function render_elements(master_ass) · 2 unmodified lines |
| 804 | 803 | |
| 805 | 804 | local ty |
| 806 | 805 | |
| 807 | | − if (an == 2) then |
| 806 | + if an == 2 then |
| 808 | 807 | ty = element.hitbox.y1 - slider_lo.border |
| 809 | 808 | else |
| 810 | | − ty = element.hitbox.y1 + elem_geo.h/2 |
| 809 | + ty = element.hitbox.y1 + elem_geo.h / 2 |
| 811 | 810 | end |
| 812 | 811 | |
| 813 | 812 | local tx = get_virt_mouse_pos() |
| 814 | | − if (slider_lo.adjust_tooltip) then |
| 815 | | − if (an == 2) then |
| 816 | | − if (sliderpos < (s_min + 3)) then |
| 813 | + if slider_lo.adjust_tooltip then |
| 814 | + if an == 2 then |
| 815 | + if sliderpos < (s_min + 3) then |
| 817 | 816 | an = an - 1 |
| 818 | | − elseif (sliderpos > (s_max - 3)) then |
| 817 | + elseif sliderpos > (s_max - 3) then |
| 819 | 818 | an = an + 1 |
| 820 | 819 | end |
| 821 | | − elseif (sliderpos > (s_max+s_min)/2) then |
| 820 | + elseif sliderpos > (s_max+s_min) / 2 then |
| 822 | 821 | an = an + 1 |
| 823 | 822 | tx = tx - 5 |
| 824 | 823 | else |
| @@ -838,20 +837,20 @@ function render_elements(master_ass) · 13 unmodified lines |
| 838 | 837 | end |
| 839 | 838 | end |
| 840 | 839 | |
| 841 | | − elseif (element.type == "button") then |
| 840 | + elseif element.type == "button" then |
| 842 | 841 | |
| 843 | 842 | local buttontext |
| 844 | 843 | if type(element.content) == "function" then |
| 845 | 844 | buttontext = element.content() -- function objects |
| 846 | | − elseif not (element.content == nil) then |
| 845 | + elseif element.content ~= nil then |
| 847 | 846 | buttontext = element.content -- text objects |
| 848 | 847 | end |
| 849 | 848 | |
| 850 | 849 | local maxchars = element.layout.button.maxchars |
| 851 | | − if not (maxchars == nil) and (#buttontext > maxchars) then |
| 850 | + if maxchars ~= nil and #buttontext > maxchars then |
| 852 | 851 | local max_ratio = 1.25 -- up to 25% more chars while shrinking |
| 853 | 852 | local limit = math.max(0, math.floor(maxchars * max_ratio) - 3) |
| 854 | | − if (#buttontext > limit) then |
| 853 | + if #buttontext > limit then |
| 855 | 854 | while (#buttontext > limit) do |
| 856 | 855 | buttontext = buttontext:gsub(".[\128-\191]*$", "") |
| 857 | 856 | end |
| @@ -1007,7 +1006,7 @@ function new_element(name, type) · 149 unmodified lines |
| 1007 | 1006 | elements[name].styledown = (type == "button") |
| 1008 | 1007 | elements[name].state = {} |
| 1009 | 1008 | |
| 1010 | | − if (type == "slider") then |
| 1009 | + if type == "slider" then |
| 1011 | 1010 | elements[name].slider = {min = {value = 0}, max = {value = 100}} |
| 1012 | 1011 | end |
| 1013 | 1012 | |
| @@ -1016,7 +1015,7 @@ function new_element(name, type) · 2 unmodified lines |
| 1016 | 1015 | end |
| 1017 | 1016 | |
| 1018 | 1017 | function add_layout(name) |
| 1019 | | − if not (elements[name] == nil) then |
| 1018 | + if elements[name] ~= nil then |
| 1020 | 1019 | -- new layout |
| 1021 | 1020 | elements[name].layout = {} |
| 1022 | 1021 | |
| @@ -1024,11 +1023,11 @@ function add_layout(name) · 1 unmodified line |
| 1024 | 1023 | elements[name].layout.layer = 50 |
| 1025 | 1024 | elements[name].layout.alpha = {[1] = 0, [2] = 255, [3] = 255, [4] = 255} |
| 1026 | 1025 | |
| 1027 | | − if (elements[name].type == "button") then |
| 1026 | + if elements[name].type == "button" then |
| 1028 | 1027 | elements[name].layout.button = { |
| 1029 | 1028 | maxchars = nil, |
| 1030 | 1029 | } |
| 1031 | | − elseif (elements[name].type == "slider") then |
| 1030 | + elseif elements[name].type == "slider" then |
| 1032 | 1031 | -- slider defaults |
| 1033 | 1032 | elements[name].layout.slider = { |
| 1034 | 1033 | border = 1, |
| @@ -1041,7 +1040,7 @@ function add_layout(name) · 6 unmodified lines |
| 1041 | 1040 | tooltip_an = 2, |
| 1042 | 1041 | alpha = {[1] = 0, [2] = 255, [3] = 88, [4] = 255}, |
| 1043 | 1042 | } |
| 1044 | | − elseif (elements[name].type == "box") then |
| 1043 | + elseif elements[name].type == "box" then |
| 1045 | 1044 | elements[name].layout.box = {radius = 0, hexagon = false} |
| 1046 | 1045 | end |
| 1047 | 1046 | |
| @@ -1196,8 +1195,8 @@ layouts["box"] = function () · 148 unmodified lines |
| 1196 | 1195 | } |
| 1197 | 1196 | |
| 1198 | 1197 | -- make sure the OSC actually fits into the video |
| 1199 | | − if (osc_param.playresx < (osc_geo.w + (2 * osc_geo.p))) then |
| 1200 | | − osc_param.playresy = (osc_geo.w+(2*osc_geo.p))/osc_param.display_aspect |
| 1198 | + if osc_param.playresx < (osc_geo.w + (2 * osc_geo.p)) then |
| 1199 | + osc_param.playresy = (osc_geo.w + (2 * osc_geo.p)) / osc_param.display_aspect |
| 1201 | 1200 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect |
| 1202 | 1201 | end |
| 1203 | 1202 | |
| @@ -1371,8 +1370,8 @@ layouts["slimbox"] = function () · 167 unmodified lines |
| 1371 | 1370 | } |
| 1372 | 1371 | |
| 1373 | 1372 | -- make sure the OSC actually fits into the video |
| 1374 | | − if (osc_param.playresx < (osc_geo.w)) then |
| 1375 | | − osc_param.playresy = (osc_geo.w)/osc_param.display_aspect |
| 1373 | + if osc_param.playresx < (osc_geo.w) then |
| 1374 | + osc_param.playresy = (osc_geo.w) / osc_param.display_aspect |
| 1376 | 1375 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect |
| 1377 | 1376 | end |
| 1378 | 1377 | |
| @@ -1423,7 +1422,7 @@ layouts["slimbox"] = function () · 44 unmodified lines |
| 1423 | 1422 | lo.style = osc_styles.box |
| 1424 | 1423 | lo.alpha[1] = user_opts.boxalpha |
| 1425 | 1424 | lo.alpha[3] = 0 |
| 1426 | | − if not (user_opts["seekbarstyle"] == "bar") then |
| 1425 | + if user_opts["seekbarstyle"] ~= "bar" then |
| 1427 | 1426 | lo.box.radius = osc_geo.r |
| 1428 | 1427 | lo.box.hexagon = user_opts["seekbarstyle"] == "diamond" |
| 1429 | 1428 | end |
| @@ -1505,7 +1504,7 @@ function bar_layout(direction) · 75 unmodified lines |
| 1505 | 1504 | padwc_r = window_control_box_width |
| 1506 | 1505 | end |
| 1507 | 1506 | |
| 1508 | | − if ((osc_param.display_aspect > 0) and (osc_param.playresx < minW)) then |
| 1507 | + if osc_param.display_aspect > 0 and osc_param.playresx < minW then |
| 1509 | 1508 | osc_param.playresy = minW / osc_param.display_aspect |
| 1510 | 1509 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect |
| 1511 | 1510 | end |
| @@ -1654,7 +1653,7 @@ function bar_layout(direction) · 142 unmodified lines |
| 1654 | 1653 | lo.style = osc_styles.timecodesBar |
| 1655 | 1654 | lo.alpha[1] = |
| 1656 | 1655 | math.min(255, user_opts.boxalpha + (255 - user_opts.boxalpha)*0.8) |
| 1657 | | − if not (user_opts["seekbarstyle"] == "bar") then |
| 1656 | + if user_opts["seekbarstyle"] ~= "bar" then |
| 1658 | 1657 | lo.box.radius = geo.h / 2 |
| 1659 | 1658 | lo.box.hexagon = user_opts["seekbarstyle"] == "diamond" |
| 1660 | 1659 | end |
| @@ -1749,7 +1748,7 @@ function osc_init() · 88 unmodified lines |
| 1749 | 1748 | local display_w, display_h, display_aspect = mp.get_osd_size() |
| 1750 | 1749 | local scale = 1 |
| 1751 | 1750 | |
| 1752 | | − if (mp.get_property("video") == "no") then -- dummy/forced window |
| 1751 | + if mp.get_property("video") == "no" then -- dummy/forced window |
| 1753 | 1752 | scale = user_opts.scaleforcedwindow |
| 1754 | 1753 | elseif state.fullscreen then |
| 1755 | 1754 | scale = user_opts.scalefullscreen |
| @@ -1763,7 +1762,7 @@ function osc_init() · 7 unmodified lines |
| 1763 | 1762 | osc_param.unscaled_y = display_h |
| 1764 | 1763 | end |
| 1765 | 1764 | osc_param.playresy = osc_param.unscaled_y / scale |
| 1766 | | − if (display_aspect > 0) then |
| 1765 | + if display_aspect > 0 then |
| 1767 | 1766 | osc_param.display_aspect = display_aspect |
| 1768 | 1767 | end |
| 1769 | 1768 | osc_param.playresx = osc_param.playresy * osc_param.display_aspect |
| @@ -1797,7 +1796,7 @@ function osc_init() · 27 unmodified lines |
| 1797 | 1796 | |
| 1798 | 1797 | ne.eventresponder["mbtn_left_up"] = function () |
| 1799 | 1798 | local title = mp.get_property_osd("media-title") |
| 1800 | | − if (have_pl) then |
| 1799 | + if have_pl then |
| 1801 | 1800 | title = string.format("[%d/%d] %s", countone(pl_pos - 1), |
| 1802 | 1801 | pl_count, title) |
| 1803 | 1802 | end |
| @@ -1926,7 +1925,7 @@ function osc_init() · 122 unmodified lines |
| 1926 | 1925 | ne.enabled = (#tracks_osc.audio > 0) |
| 1927 | 1926 | ne.content = function () |
| 1928 | 1927 | local aid = "–" |
| 1929 | | − if not (get_track("audio") == 0) then |
| 1928 | + if get_track("audio") ~= 0 then |
| 1930 | 1929 | aid = get_track("audio") |
| 1931 | 1930 | end |
| 1932 | 1931 | return ("\238\132\134" .. osc_styles.smallButtonsLlabel |
| @@ -1949,7 +1948,7 @@ function osc_init() · 16 unmodified lines |
| 1949 | 1948 | ne.enabled = (#tracks_osc.sub > 0) |
| 1950 | 1949 | ne.content = function () |
| 1951 | 1950 | local sid = "–" |
| 1952 | | − if not (get_track("sub") == 0) then |
| 1951 | + if get_track("sub") ~= 0 then |
| 1953 | 1952 | sid = get_track("sub") |
| 1954 | 1953 | end |
| 1955 | 1954 | return ("\238\132\135" .. osc_styles.smallButtonsLlabel |
| @@ -1969,7 +1968,7 @@ function osc_init() · 13 unmodified lines |
| 1969 | 1968 | --tog_fs |
| 1970 | 1969 | ne = new_element("tog_fs", "button") |
| 1971 | 1970 | ne.content = function () |
| 1972 | | − if (state.fullscreen) then |
| 1971 | + if state.fullscreen then |
| 1973 | 1972 | return ("\238\132\137") |
| 1974 | 1973 | else |
| 1975 | 1974 | return ("\238\132\136") |
| @@ -1981,11 +1980,11 @@ function osc_init() · 5 unmodified lines |
| 1981 | 1980 | --seekbar |
| 1982 | 1981 | ne = new_element("seekbar", "slider") |
| 1983 | 1982 | |
| 1984 | | − ne.enabled = not (mp.get_property("percent-pos") == nil) |
| 1983 | + ne.enabled = mp.get_property("percent-pos") ~= nil |
| 1985 | 1984 | state.slider_element = ne.enabled and ne or nil -- used for forced_title |
| 1986 | 1985 | ne.slider.markerF = function () |
| 1987 | 1986 | local duration = mp.get_property_number("duration", nil) |
| 1988 | | − if not (duration == nil) then |
| 1987 | + if duration ~= nil then |
| 1989 | 1988 | local chapters = mp.get_property_native("chapter-list", {}) |
| 1990 | 1989 | local markers = {} |
| 1991 | 1990 | for n = 1, #chapters do |
| @@ -2000,7 +1999,7 @@ function osc_init() · 8 unmodified lines |
| 2000 | 1999 | function () return mp.get_property_number("percent-pos", nil) end |
| 2001 | 2000 | ne.slider.tooltipF = function (pos) |
| 2002 | 2001 | local duration = mp.get_property_number("duration", nil) |
| 2003 | | − if not ((duration == nil) or (pos == nil)) then |
| 2002 | + if duration ~= nil and pos ~= nil then |
| 2004 | 2003 | possec = duration * (pos / 100) |
| 2005 | 2004 | return mp.format_time(possec) |
| 2006 | 2005 | else |
| @@ -2016,7 +2015,7 @@ function osc_init() · 9 unmodified lines |
| 2016 | 2015 | return nil |
| 2017 | 2016 | end |
| 2018 | 2017 | local duration = mp.get_property_number("duration", nil) |
| 2019 | | − if (duration == nil) or duration <= 0 then |
| 2018 | + if duration == nil or duration <= 0 then |
| 2020 | 2019 | return nil |
| 2021 | 2020 | end |
| 2022 | 2021 | local ranges = cache_state["seekable-ranges"] |
| @@ -2038,8 +2037,8 @@ function osc_init() · 15 unmodified lines |
| 2038 | 2037 | -- sent when the user is done seeking, so we need to throw away |
| 2039 | 2038 | -- identical seeks |
| 2040 | 2039 | local seekto = get_slider_value(element) |
| 2041 | | − if (element.state.lastseek == nil) or |
| 2042 | | − (not (element.state.lastseek == seekto)) then |
| 2040 | + if element.state.lastseek == nil or |
| 2041 | + element.state.lastseek ~= seekto then |
| 2043 | 2042 | local flags = "absolute-percent" |
| 2044 | 2043 | if not user_opts.seekbarkeyframes then |
| 2045 | 2044 | flags = flags .. "+exact" |
| @@ -2064,7 +2063,7 @@ function osc_init() · 18 unmodified lines |
| 2064 | 2063 | ne = new_element("tc_left", "button") |
| 2065 | 2064 | |
| 2066 | 2065 | ne.content = function () |
| 2067 | | − if (state.tc_ms) then |
| 2066 | + if state.tc_ms then |
| 2068 | 2067 | return (mp.get_property_osd("playback-time/full")) |
| 2069 | 2068 | else |
| 2070 | 2069 | return (mp.get_property_osd("playback-time")) |
| @@ -2080,7 +2079,7 @@ function osc_init() · 9 unmodified lines |
| 2080 | 2079 | |
| 2081 | 2080 | ne.visible = (mp.get_property_number("duration", 0) > 0) |
| 2082 | 2081 | ne.content = function () |
| 2083 | | − if (state.rightTC_trem) then |
| 2082 | + if state.rightTC_trem then |
| 2084 | 2083 | local minus = user_opts.unicodeminus and UNICODE_MINUS or "-" |
| 2085 | 2084 | local property = user_opts.remaining_playtime and "playtime-remaining" |
| 2086 | 2085 | or "time-remaining" |
| @@ -2174,7 +2173,7 @@ function update_margins() · 87 unmodified lines |
| 2174 | 2173 | local margins = osc_param.video_margins |
| 2175 | 2174 | |
| 2176 | 2175 | -- Don't use margins if it's visible only temporarily. |
| 2177 | | − if (not state.osc_visible) or (get_hidetimeout() >= 0) or |
| 2176 | + if not state.osc_visible or get_hidetimeout() >= 0 or |
| 2178 | 2177 | (state.fullscreen and not user_opts.showfullscreen) or |
| 2179 | 2178 | (not state.fullscreen and not user_opts.showwindowed) |
| 2180 | 2179 | then |
| @@ -2196,7 +2195,7 @@ function update_margins() · 15 unmodified lines |
| 2196 | 2195 | if not margins_used then |
| 2197 | 2196 | for _, opt in ipairs(margins_opts) do |
| 2198 | 2197 | local v = margins[opt[1]] |
| 2199 | | − if (v ~= 0) or state.using_video_margins then |
| 2198 | + if v ~= 0 or state.using_video_margins then |
| 2200 | 2199 | mp.set_property_number(opt[2], v) |
| 2201 | 2200 | state.using_video_margins = true |
| 2202 | 2201 | end |
| @@ -2229,7 +2228,7 @@ function show_osc() · 26 unmodified lines |
| 2229 | 2228 | |
| 2230 | 2229 | osc_visible(true) |
| 2231 | 2230 | |
| 2232 | | − if (user_opts.fadeduration > 0) then |
| 2231 | + if user_opts.fadeduration > 0 then |
| 2233 | 2232 | state.anitype = nil |
| 2234 | 2233 | end |
| 2235 | 2234 | end |
| @@ -2241,8 +2240,8 @@ function hide_osc() · 5 unmodified lines |
| 2241 | 2240 | -- no-op and won't render again to remove the osc, so do that manually. |
| 2242 | 2241 | state.osc_visible = false |
| 2243 | 2242 | render_wipe() |
| 2244 | | − elseif (user_opts.fadeduration > 0) then |
| 2245 | | − if not(state.osc_visible == false) then |
| 2243 | + elseif user_opts.fadeduration > 0 then |
| 2244 | + if state.osc_visible then |
| 2246 | 2245 | state.anitype = "out" |
| 2247 | 2246 | request_tick() |
| 2248 | 2247 | end |
| @@ -2324,8 +2323,8 @@ function render() · 75 unmodified lines |
| 2324 | 2323 | local now = mp.get_time() |
| 2325 | 2324 | |
| 2326 | 2325 | -- check if display changed, if so request reinit |
| 2327 | | − if not (state.mp_screen_sizeX == current_screen_sizeX |
| 2328 | | − and state.mp_screen_sizeY == current_screen_sizeY) then |
| 2326 | + if state.mp_screen_sizeX ~= current_screen_sizeX |
| 2327 | + or state.mp_screen_sizeY ~= current_screen_sizeY then |
| 2329 | 2328 | |
| 2330 | 2329 | request_init_resize() |
| 2331 | 2330 | |
| @@ -2355,27 +2354,27 @@ function render() · 23 unmodified lines |
| 2355 | 2354 | |
| 2356 | 2355 | |
| 2357 | 2356 | -- fade animation |
| 2358 | | − if not(state.anitype == nil) then |
| 2357 | + if state.anitype ~= nil then |
| 2359 | 2358 | |
| 2360 | | − if (state.anistart == nil) then |
| 2359 | + if state.anistart == nil then |
| 2361 | 2360 | state.anistart = now |
| 2362 | 2361 | end |
| 2363 | 2362 | |
| 2364 | | − if (now < state.anistart + (user_opts.fadeduration/1000)) then |
| 2363 | + if now < state.anistart + (user_opts.fadeduration / 1000) then |
| 2365 | 2364 | |
| 2366 | | − if (state.anitype == "in") then --fade in |
| 2365 | + if state.anitype == "in" then --fade in |
| 2367 | 2366 | osc_visible(true) |
| 2368 | 2367 | state.animation = scale_value(state.anistart, |
| 2369 | | − (state.anistart + (user_opts.fadeduration/1000)), |
| 2368 | + (state.anistart + (user_opts.fadeduration / 1000)), |
| 2370 | 2369 | 255, 0, now) |
| 2371 | | − elseif (state.anitype == "out") then --fade out |
| 2370 | + elseif state.anitype == "out" then --fade out |
| 2372 | 2371 | state.animation = scale_value(state.anistart, |
| 2373 | | − (state.anistart + (user_opts.fadeduration/1000)), |
| 2372 | + (state.anistart + (user_opts.fadeduration / 1000)), |
| 2374 | 2373 | 0, 255, now) |
| 2375 | 2374 | end |
| 2376 | 2375 | |
| 2377 | 2376 | else |
| 2378 | | − if (state.anitype == "out") then |
| 2377 | + if state.anitype == "out" then |
| 2379 | 2378 | osc_visible(false) |
| 2380 | 2379 | end |
| 2381 | 2380 | kill_animation() |
| @@ -2413,7 +2412,7 @@ function render() · 31 unmodified lines |
| 2413 | 2412 | state.input_enabled = state.osc_visible |
| 2414 | 2413 | end |
| 2415 | 2414 | |
| 2416 | | − if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then |
| 2415 | + if mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2) then |
| 2417 | 2416 | mouse_over_osc = true |
| 2418 | 2417 | end |
| 2419 | 2418 | end |
| @@ -2432,7 +2431,7 @@ function render() · 12 unmodified lines |
| 2432 | 2431 | state.windowcontrols_buttons = state.osc_visible |
| 2433 | 2432 | end |
| 2434 | 2433 | |
| 2435 | | − if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then |
| 2434 | + if mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2) then |
| 2436 | 2435 | mouse_over_osc = true |
| 2437 | 2436 | end |
| 2438 | 2437 | end |
| @@ -2440,17 +2439,17 @@ function render() · 1 unmodified line |
| 2440 | 2439 | |
| 2441 | 2440 | if osc_param.areas["window-controls-title"] then |
| 2442 | 2441 | for _,cords in ipairs(osc_param.areas["window-controls-title"]) do |
| 2443 | | − if (mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2)) then |
| 2442 | + if mouse_hit_coords(cords.x1, cords.y1, cords.x2, cords.y2) then |
| 2444 | 2443 | mouse_over_osc = true |
| 2445 | 2444 | end |
| 2446 | 2445 | end |
| 2447 | 2446 | end |
| 2448 | 2447 | |
| 2449 | 2448 | -- autohide |
| 2450 | | − if not (state.showtime == nil) and (get_hidetimeout() >= 0) then |
| 2451 | | − local timeout = state.showtime + (get_hidetimeout()/1000) - now |
| 2449 | + if state.showtime ~= nil and get_hidetimeout() >= 0 then |
| 2450 | + local timeout = state.showtime + (get_hidetimeout() / 1000) - now |
| 2452 | 2451 | if timeout <= 0 then |
| 2453 | | − if (state.active_element == nil) and not (mouse_over_osc) then |
| 2452 | + if state.active_element == nil and not mouse_over_osc then |
| 2454 | 2453 | hide_osc() |
| 2455 | 2454 | end |
| 2456 | 2455 | else |
| @@ -2544,8 +2543,8 @@ function process_event(source, what) · 87 unmodified lines |
| 2544 | 2543 | state.mouse_in_window = true |
| 2545 | 2544 | |
| 2546 | 2545 | local mouseX, mouseY = get_virt_mouse_pos() |
| 2547 | | − if (user_opts.minmousemove == 0) or |
| 2548 | | − (not ((state.last_mouseX == nil) or (state.last_mouseY == nil)) and |
| 2546 | + if user_opts.minmousemove == 0 or |
| 2547 | + ((state.last_mouseX ~= nil and state.last_mouseY ~= nil) and |
| 2549 | 2548 | ((math.abs(mouseX - state.last_mouseX) >= user_opts.minmousemove) |
| 2550 | 2549 | or (math.abs(mouseY - state.last_mouseY) >= user_opts.minmousemove) |
| 2551 | 2550 | ) |
| @@ -2597,9 +2596,9 @@ function tick() · 45 unmodified lines |
| 2597 | 2596 | state.marginsREQ = false |
| 2598 | 2597 | end |
| 2599 | 2598 | |
| 2600 | | − if (not state.enabled) then return end |
| 2599 | + if not state.enabled then return end |
| 2601 | 2600 | |
| 2602 | | − if (state.idle) then |
| 2601 | + if state.idle then |
| 2603 | 2602 | |
| 2604 | 2603 | -- render idle message |
| 2605 | 2604 | msg.trace("idle message") |
| @@ -2645,7 +2644,7 @@ function tick() · 39 unmodified lines |
| 2645 | 2644 | end |
| 2646 | 2645 | |
| 2647 | 2646 | |
| 2648 | | − elseif (state.fullscreen and user_opts.showfullscreen) |
| 2647 | + elseif state.fullscreen and user_opts.showfullscreen |
| 2649 | 2648 | or (not state.fullscreen and user_opts.showwindowed) then |
| 2650 | 2649 | |
| 2651 | 2650 | -- render the OSC |
| @@ -2708,7 +2707,7 @@ function update_duration_watch() · 56 unmodified lines |
| 2708 | 2707 | (mp.get_property_number("chapters", 0) or 0) > 0 and |
| 2709 | 2708 | true or false -- ensure it's a boolean |
| 2710 | 2709 | |
| 2711 | | − if (want_watch ~= duration_watched) then |
| 2710 | + if want_watch ~= duration_watched then |
| 2712 | 2711 | if want_watch then |
| 2713 | 2712 | mp.observe_property("duration", nil, on_duration) |
| 2714 | 2713 | else |