Skip to content
Permalink
Browse files

Fix #2424

  • Loading branch information...
saagarjha committed May 29, 2019
1 parent 425f221 commit 818b43680f8eb194b63636ec27bfd1ceff141e70
Showing with 12 additions and 3 deletions.
  1. +12 −3 iina/MenuController.swift
@@ -396,12 +396,21 @@ class MenuController: NSObject, NSMenuDelegate {
private func updateChapterList() {
chapterMenu.removeAllItems()
let info = PlayerCore.active.info
let padder = { (time: String) -> String in
let standard = (info.chapters.last?.time.stringRepresentation ?? "").reversed()
return String((time.reversed() + standard[standard.index(standard.startIndex, offsetBy: time.count)...].map {
$0 == ":" ? ":" : "0"
}).reversed())
}
for (index, chapter) in info.chapters.enumerated() {
let menuTitle = "\(chapter.time.stringRepresentation) - \(chapter.title)"
let menuTitle = "\(padder(chapter.time.stringRepresentation)) \(chapter.title)"
let nextChapterTime = info.chapters[at: index+1]?.time ?? Constants.Time.infinite
let isPlaying = info.videoPosition?.between(chapter.time, nextChapterTime) ?? false
chapterMenu.addItem(withTitle: menuTitle, action: #selector(MainMenuActionHandler.menuChapterSwitch(_:)),
tag: index, obj: nil, stateOn: isPlaying)
let menuItem = NSMenuItem(title: menuTitle, action: #selector(MainMenuActionHandler.menuChapterSwitch(_:)), keyEquivalent: "")
menuItem.tag = index
menuItem.state = isPlaying ? .on : .off
menuItem.attributedTitle = NSAttributedString(string: menuTitle, attributes: [.font: NSFont.monospacedDigitSystemFont(ofSize: 0, weight: .regular)])
chapterMenu.addItem(menuItem)
}
}

0 comments on commit 818b436

Please sign in to comment.
You can’t perform that action at this time.