~mil/mepo

ref: c9af5f468e9039fbd4db9fce35cf7633b04effcd mepo/src/api/preftoggle.zig -rw-r--r-- 1.3 KiB
c9af5f46Miles Alan Move crosshair_size to prefs system 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
28
29
30
31
32
33
34
35
const Mepo = @import("../Mepo.zig");
const types = @import("../types.zig");
const std = @import("std");
const utildbg = @import("../util/utildbg.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: *Mepo, args: [types.MepoFnNargs]types.MepoArg) !void {
    const name = args[0].Text;

    mepo.prefs.toggle_bool(name);

    //for (&[_]struct { prop: []const u8, ptr: *bool }{
    //    .{ .prop = "help", .ptr = &mepo.help },
    //    .{ .prop = "overlay_debugbar", .ptr = &mepo.overlay_debugbar },
    //    .{ .prop = "overlay_pindetails", .ptr = &mepo.overlay_pindetails },
    //    .{ .prop = "debug_message_enabled", .ptr = &mepo.debug_message_enabled },
    //    .{ .prop = "debug_tiles", .ptr = &mepo.debug_tiles },
    //    .{ .prop = "debug_stderr", .ptr = &utildbg.debug_stderr },
    //}) |stg| {
    //    if (std.mem.eql(u8, stg.prop, name)) stg.ptr.* = !stg.ptr.*;
    //}

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