~mil/mepo

ref: 4bb3b55aac499ba4f85180006c6b69976c6c0a14 mepo/src/api/preftoggle.zig -rw-r--r-- 798 bytes
4bb3b55aMiles Alan Move prefrences into global / utilprefs rather then object structure 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const Mepo = @import("../Mepo.zig");
const types = @import("../types.zig");
const std = @import("std");
const utildbg = @import("../util/utildbg.zig");
const utilprefs = @import("../util/utilprefs.zig");

pub const spec = .{
    .name = "preftoggle",
    .desc = "Toggle a boolean number preference between `1` and `0`",
    // TODO: document prefrences table
    .args = (&[_]types.MepoFnSpecArg{
        .{ .tag = .Text, .name = "prefname", .desc = "Preference name" },
    })[0..],
    .execute = execute,
};

fn execute(_: *Mepo, args: [types.MepoFnNargs]types.MepoArg) !void {
    const name = args[0].Text;

    utilprefs.toggle_bool(name);

    //if (std.mem.eql(u8, "tile_cache_network", name)) {
    //    mepo.tile_cache.set_network(!(mepo.tile_cache.thread_download != null));
    //}
}