module patch.alpha;

import std.algorithm : clamp;
import config : alpha;
import st : Arg, redraw;
import win : xloadcols;
import patches : isPatchEnabled;

static if (isPatchEnabled!"ALPHA_FOCUS_HIGHLIGHT_PATCH") {
    import config : alphaUnfocused;
}

void changealpha(const(Arg)* arg) {
    if ((alpha > 0 && arg.f < 0) || (alpha < 1 && arg.f > 0))
        alpha += arg.f;
    alpha = clamp(alpha, 0.0f, 1.0f);
    xloadcols();
    redraw();
}

static if (isPatchEnabled!"ALPHA_FOCUS_HIGHLIGHT_PATCH") {
    void changealphaunfocused(const(Arg)* arg) {
        if ((alphaUnfocused > 0 && arg.f < 0) || (alphaUnfocused < 1 && arg.f > 0))
            alphaUnfocused += arg.f;
        alphaUnfocused = clamp(alphaUnfocused, 0.0f, 1.0f);
        xloadcols();
        redraw();
    }
}