Skip to content
This repository has been archived by the owner on Sep 16, 2023. It is now read-only.

Commit

Permalink
Honor Enable advanced settings config
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Dec 23, 2021
1 parent 86c6745 commit 869d7af
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion iina/Logger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct Logger {
}
}

static let enabled = Preference.bool(for: .enableLogging)
static let enabled = Preference.bool(for: .enableAdvancedSettings) && Preference.bool(for: .enableLogging)

static let logDirectory: URL = {
let formatter = DateFormatter()
Expand Down
36 changes: 19 additions & 17 deletions iina/MPVController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ class MPVController: NSObject {
// - Advanced

// disable internal OSD
let useMpvOsd = Preference.bool(for: .useMpvOsd)
let useMpvOsd = Preference.bool(for: .enableAdvancedSettings) && Preference.bool(for: .useMpvOsd)
if !useMpvOsd {
chkErr(mpv_set_option_string(mpv, MPVOption.OSD.osdLevel, "0"))
} else {
Expand Down Expand Up @@ -285,28 +285,30 @@ class MPVController: NSObject {
"\(MPVOption.PlaybackControl.abLoopA),\(MPVOption.PlaybackControl.abLoopB)"))

// Set user defined conf dir.
if Preference.bool(for: .useUserDefinedConfDir) {
if var userConfDir = Preference.string(for: .userDefinedConfDir) {
userConfDir = NSString(string: userConfDir).standardizingPath
mpv_set_option_string(mpv, "config", "yes")
let status = mpv_set_option_string(mpv, MPVOption.ProgramBehavior.configDir, userConfDir)
if status < 0 {
Utility.showAlert("extra_option.config_folder", arguments: [userConfDir])
}
if Preference.bool(for: .enableAdvancedSettings),
Preference.bool(for: .useUserDefinedConfDir),
var userConfDir = Preference.string(for: .userDefinedConfDir) {
userConfDir = NSString(string: userConfDir).standardizingPath
mpv_set_option_string(mpv, "config", "yes")
let status = mpv_set_option_string(mpv, MPVOption.ProgramBehavior.configDir, userConfDir)
if status < 0 {
Utility.showAlert("extra_option.config_folder", arguments: [userConfDir])
}
}

// Set user defined options.
if let userOptions = Preference.value(for: .userOptions) as? [[String]] {
userOptions.forEach { op in
let status = mpv_set_option_string(mpv, op[0], op[1])
if status < 0 {
Utility.showAlert("extra_option.error", arguments:
[op[0], op[1], status])
if Preference.bool(for: .enableAdvancedSettings) {
if let userOptions = Preference.value(for: .userOptions) as? [[String]] {
userOptions.forEach { op in
let status = mpv_set_option_string(mpv, op[0], op[1])
if status < 0 {
Utility.showAlert("extra_option.error", arguments:
[op[0], op[1], status])
}
}
} else {
Utility.showAlert("extra_option.cannot_read")
}
} else {
Utility.showAlert("extra_option.cannot_read")
}

// Load external scripts
Expand Down

0 comments on commit 869d7af

Please sign in to comment.