From f2d726a9cff2e7cc97c55cecd4748aaad905f12c Mon Sep 17 00:00:00 2001 From: TheDukeofErl Date: Tue, 24 May 2022 19:16:23 -0500 Subject: [PATCH] When filter is selected but no device is selected show unconfigured. --- ui.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/ui.go b/ui.go index 7de5520..5f417a9 100644 --- a/ui.go +++ b/ui.go @@ -88,7 +88,13 @@ func mainView(ctx *ntcontext, w *nucular.Window) { w.LabelColored("NoiseTorch unconfigured", "RC", lightBlue) } } else if ctx.noiseSupressorState == unloaded { - w.LabelColored("NoiseTorch inactive", "RC", red) + _, inpOk := inputSelection(ctx) + _, outOk := outputSelection(ctx) + if validConfiguration(ctx, inpOk, outOk) { + w.LabelColored("NoiseTorch inactive", "RC", red) + } else { + w.LabelColored("NoiseTorch unconfigured", "RC", lightBlue) + } } else if ctx.noiseSupressorState == inconsistent { w.LabelColored("Inconsistent state, please unload first.", "RC", orange) } @@ -237,10 +243,7 @@ func mainView(ctx *ntcontext, w *nucular.Window) { inp, inpOk := inputSelection(ctx) out, outOk := outputSelection(ctx) - if (!ctx.config.FilterInput || (ctx.config.FilterInput && inpOk)) && - (!ctx.config.FilterOutput || (ctx.config.FilterOutput && outOk)) && - (ctx.config.FilterInput || ctx.config.FilterOutput) && - ctx.noiseSupressorState != inconsistent { + if validConfiguration(ctx, inpOk, outOk) { if w.ButtonText(txt) { ctx.reloadRequired = false @@ -339,6 +342,13 @@ func outputSelection(ctx *ntcontext) (device, bool) { return device{}, false } +func validConfiguration(ctx *ntcontext, inpOk bool, outOk bool) (bool) { + return (!ctx.config.FilterInput || (ctx.config.FilterInput && inpOk)) && + (!ctx.config.FilterOutput || (ctx.config.FilterOutput && outOk)) && + (ctx.config.FilterInput || ctx.config.FilterOutput) && + ctx.noiseSupressorState != inconsistent +} + func loadingView(ctx *ntcontext, w *nucular.Window) { w.Row(50).Dynamic(1) w.Label("Working...", "CB")