~mil/mepo

21f2bffaaa4a31031dea1ec2981c800ee1ab3d2a — Miles Alan a month ago abd9bfc
Stub out tile cache preferences in utilprefs; restore offline/online functionality
2 files changed, 25 insertions(+), 9 deletions(-)

M src/api/prefset_n.zig
M src/util/utilprefs.zig
M src/api/prefset_n.zig => src/api/prefset_n.zig +6 -6
@@ 15,13 15,13 @@ pub const spec = .{
    .execute = execute,
};

fn execute(_: *Mepo, args: [types.MepoFnNargs]types.MepoArg) !void {
fn execute(mepo: *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);
    //}
    if (std.mem.eql(u8, "tile_cache_network", name)) {
        mepo.tile_cache.set_network(value == 1);
    } else {
        utilprefs.set_n(name, value);
    }
}

M src/util/utilprefs.zig => src/util/utilprefs.zig +19 -3
@@ 1,14 1,14 @@
const std = @import("std");

const PrefValueEnum = enum { b, t, f, u };
const PrefValueUnion = union(PrefValueEnum) { b: bool, t: []const u8, f: f64, u: u8 };
const PrefValueEnum = enum { b, t, f, u, v };
const PrefValueUnion = union(PrefValueEnum) { b: bool, t: []const u8, f: f64, u: u8, v: void };
const PrefMapping = struct {
    name: []const u8,
    value: PrefValueUnion,
    desc: []const u8,
};

const n_prefs = 13;
const n_prefs = 16;
var prefs_mapping: [n_prefs]PrefMapping = mapping: {
    var mapping: [n_prefs]PrefMapping = undefined;
    mapping[0] = .{


@@ 76,6 76,21 @@ var prefs_mapping: [n_prefs]PrefMapping = mapping: {
        .value = .{ .f = -1 },
        .desc = "TODO",
    };
    mapping[13] = .{
        .name = "tile_cache_network",
        .value = .{ .v = void{} },
        .desc = "TODO",
    };
    mapping[14] = .{
        .name = "tile_cache_dir",
        .value = .{ .v = void{} },
        .desc = "TODO",
    };
    mapping[15] = .{
        .name = "tile_cache_url",
        .value = .{ .v = void{} },
        .desc = "TODO",
    };
    break :mapping mapping;
};



@@ 109,6 124,7 @@ pub fn set_n(prefname: []const u8, value: f64) void {
                    pref.value = .{ .f = value };
                },
                .t => {},
                .v => {},
            }
        }
    }