Skip to content

Commit

Permalink
Add message box to tell you to update your config on first startup
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed Aug 20, 2023
1 parent 63e0a6d commit 0f9ce08
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
13 changes: 12 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
const std = @import("std");

pub fn build(b: *std.Build) void {
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const zboxer = b.dependency("zBoxer", .{
.target = target,
.optimize = optimize,
});
const zboxer_lib = zboxer.artifact("boxer");

const exe = b.addExecutable(.{
.name = "FreshPresence",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
if (target.getOsTag() == .macos) {
@import("xcode_frameworks").addPaths(b, exe);
}
exe.linkLibrary(zboxer_lib);
try exe.include_dirs.appendSlice(zboxer_lib.include_dirs.items);
exe.linkLibC();
exe.addModule("rpc", b.dependency("zig-discord", .{}).module("rpc"));
b.installArtifact(exe);
Expand Down
8 changes: 8 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@
.url = "https://github.com/Beyley/zig-discord/archive/d5af305592f5712a0731554e2afd10afbea293cc.tar.gz",
.hash = "1220af3afee845035705462f357f7ca70b964787a94ff3ae39a6ee779f3cca452880",
},
.zBoxer = .{
.url = "https://github.com/Beyley/zBoxer/archive/8ba46a2fe50d658f1406c9681b8b931df24edf37.tar.gz",
.hash = "1220f0d56067829895dfbedbae59cc9579a484f7fee8f93a7db5a1d2eadcfcbf97d9",
},
.xcode_frameworks = .{
.url = "https://github.com/hexops/xcode-frameworks-pkg/archive/d486474a6af7fafd89e8314e0bf7eca4709f811b.tar.gz",
.hash = "1220293eae4bf67a7c27a18a8133621337cde91a97bc6859a9431b3b2d4217dfb5fb",
},
},
}
13 changes: 12 additions & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const Config = struct {
}
};

const c = @cImport({
@cInclude("boxer/boxer.h");
});

/// Checks for an existing config, returns `true` if there is a config, `false` if not
/// Writes a default config if missing
pub fn getConfig(allocator: std.mem.Allocator) !Config {
Expand All @@ -33,7 +37,14 @@ pub fn getConfig(allocator: std.mem.Allocator) !Config {
try std.json.stringify(default_config, .{}, buffered_writer.writer());
try buffered_writer.flush();

return error.ConfigWrittenPleaseUpdate;
if (c.boxerShow(
"Config created at " ++ config_path ++ "! Please check your config!",
"Update Config!",
c.kBoxerDefaultStyle,
c.kBoxerDefaultStyle,
) == c.BoxerSelectionError) {}

std.os.exit(0);
} else {
return err;
}
Expand Down

0 comments on commit 0f9ce08

Please sign in to comment.