UI.AddMultiDropdown("indicators", ["watermark", "keybinds"]);

UI.AddColorPicker("color");



const screen_size = Global.GetScreenSize();

var stored = false;

var x_offs = 0;

var y_offs = 0;



UI.AddSliderInt("binds x", 0, screen_size[0]);

UI.AddSliderInt("binds y", 0, screen_size[1]);

UI.SetEnabled("Script items", "binds x", false);

UI.SetEnabled("Script items", "binds y", false);



const get_dropdown_value = function(value, index) {

    const mask = 1 << index;

    return value & mask ? true : false;

}



const in_bounds = function(vec, x, y, x2, y2) {

    return (vec[0] > x) && (vec[1] > y) && (vec[0] < x2) && (vec[1] < y2)

}



const watermark = function() {

    const user = Cheat.GetUsername();

    const ping = Math.round(Local.Latency() * 1000 - 16);

    const now = new Date();

    const hours = now.getHours(),

        mins = now.getMinutes(),

        secs = now.getSeconds();

    const time = (hours < 10 ? "0" + hours : hours) + ":" + (mins < 10 ? "0" + mins : mins) + ":" + (secs < 10 ? "0" + secs : secs);

    const font = Render.AddFont("Calibri", 10, 100);

    const color = UI.GetColor("Script items", "color");

    const text = "acid.tech [beta] | " + user + " | ";

    if (World.GetServerString() != "") {

        text += "" + ping + " ms | " + Globals.Tickrate() + " tick | ";

    }

    text += time;

    const w = Render.TextSizeCustom(text, font)[0] + 10;

    const x = screen_size[0];

    x = x - w - 10;



    Render.FilledRect(x, 12, w, 18, [0, 0, 0, color[3]]);

    Render.StringCustom(x + 5, 13, 0, text, [255, 255, 255, 255], font);



    Render.GradientRect(x, 10, w / 2, 2, 2, [55, 177, 218 /*55, 177, 218*/ , 255], [203, 70, 205 /*203, 70, 205*/ , 255]);

    Render.GradientRect(x + w / 2, 10, w / 2, 2, 2, [203, 70, 205 /*203, 70, 205*/ , 255], [204, 227, 53 /*204, 227, 53*/ , 255]);



}



const keybinds = function() {

    var keybinds = [];

    if (UI.IsMenuOpen()) {

        keybinds.push("Menu is Open")

    };

    if (UI.GetValue("Anti-Aim", "Rage Anti-Aim", "Auto direction")) {

        keybinds.push("Freestand")

    };

    if (UI.IsHotkeyActive("Rage", "Exploits", "Double tap")) {

        keybinds.push("Double tap")

    };

    if (UI.IsHotkeyActive("Rage", "Exploits", "Hide shots")) {

        keybinds.push("Hide shots")

    };

    if (UI.IsHotkeyActive("Anti-Aim", "Extra", "Fake duck")) {

        keybinds.push("Duck peek assist")

    };

    if (UI.IsHotkeyActive("Rage", "General", "General", "Force body aim")) {

        keybinds.push("Body aim")

    };

    if (UI.IsHotkeyActive("Rage", "General", "General", "Force safe point")) {

        keybinds.push("Safe point")

    };

    if (UI.IsHotkeyActive("Script items", "min damage")) {

        keybinds.push("Minimum damage")

    };



    const x = UI.GetValue("Script items", "binds x"),

        y = UI.GetValue("Script items", "binds y");

    const font = Render.AddFont("Calibri", 10, 100);

    const color = UI.GetColor("Script items", "color");



    Render.FilledRect(x, y, 150, 18, [0, 0, 0, color[3]]);

    Render.StringCustom(x + 75, y + 1, 1, "keybinds", [255, 255, 255, 255], font);

    for (i = 0; i < keybinds.length; i++) {

        Render.StringCustom(x + 1, y + 18 + 15 * i, 0, keybinds[i], [255, 255, 255, 255], font);

        Render.StringCustom(x + 128, y + 18 + 15 * i, 0, "[on]", [255, 255, 255, 255], font);

    }



    Render.GradientRect(x, y - 2, 75, 2, 2, [55, 177, 218 /*55, 177, 218*/ , 255], [203, 70, 205 /*203, 70, 205*/ , 255]);

    Render.GradientRect(x + 75, y - 2, 75, 2, 2, [203, 70, 205 /*203, 70, 205*/ , 255], [204, 227, 53 /*204, 227, 53*/ , 255]);





    if (UI.IsMenuOpen() && Input.IsKeyPressed(0x1)) {

        const mouse_pos = Global.GetCursorPosition();

        if (in_bounds(mouse_pos, x, y, x + 150, y + 40)) {

            if (!stored) {

                x_offs = mouse_pos[0] - x;

                y_offs = mouse_pos[1] - y;

                stored = true;

            }

            UI.SetValue("Script items", "binds x", mouse_pos[0] - x_offs);

            UI.SetValue("Script items", "binds y", mouse_pos[1] - y_offs);

        }

    } else if (stored) stored = false;

}



const draw = function() {

    if (get_dropdown_value(UI.GetValue("indicators"), 0))

        watermark();



    if (get_dropdown_value(UI.GetValue("indicators"), 1))

        keybinds();



}



Cheat.RegisterCallback("Draw", "draw");