~mil/mepo

ref: 4bb3b55aac499ba4f85180006c6b69976c6c0a14 mepo/src/api/prefset_n.zig -rw-r--r-- 868 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
26
27
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 = "prefset_n",
    .desc = "Set a preference number value",
    // TODO: document preference mapping table
    .args = (&[_]types.MepoFnSpecArg{
        .{ .tag = .Text, .name = "prefname", .desc = "Preference name" },
        .{ .tag = .Number, .name = "prefvalue", .desc = "Preference number value" },
    })[0..],
    .execute = execute,
};

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

    utilprefs.set_n(name, value);

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