Skip to content

Commit c99906a

Browse files
author
Jay
committed
Update modules
1 parent e339952 commit c99906a

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

build.zig.zon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.{
22
.name = .engine,
3-
.version = "0.7.1",
3+
.version = "0.7.3",
44
.fingerprint = 0xe8a81a8d0aa558d5,
55
.minimum_zig_version = "0.15.2",
66
.dependencies = .{

src/engine.zig

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2587,9 +2587,10 @@ pub const Display = struct {
25872587
app_version: [:0]const u8,
25882588
app_id: [:0]const u8,
25892589
dev_resource_folder: []const u8,
2590+
dev_resource_filter: ?fn (name: []const u8, extension: Resource.Type) bool,
25902591
translation_filename: []const u8,
25912592
gui_flags: usize,
2592-
) (Error || Allocator.Error || Resources.Error || error{ Utf8ExpectedContinuation, Utf8OverlongEncoding, Utf8EncodesSurrogateHalf, Utf8CodepointTooLarge, Utf8InvalidStartByte })!*Display {
2593+
) (Error || Allocator.Error || Resources.Error || engine.Error || error{ Utf8ExpectedContinuation, Utf8OverlongEncoding, Utf8EncodesSurrogateHalf, Utf8CodepointTooLarge, Utf8InvalidStartByte } || std.fs.Dir.StatError || std.fs.File.StatError || std.fs.File.OpenError)!*Display {
25932594
var display = try gpa.create(Display);
25942595
errdefer gpa.destroy(display);
25952596
display.allocator = gpa;
@@ -2651,7 +2652,12 @@ pub const Display = struct {
26512652
}
26522653

26532654
debug("Initialising resource loader", .{});
2654-
display.resources = try init_resource_loader(gpa, engine.RESOURCE_BUNDLE_FILENAME, dev_resource_folder);
2655+
display.resources = try init_resource_loader(
2656+
gpa,
2657+
engine.RESOURCE_BUNDLE_FILENAME,
2658+
dev_resource_folder,
2659+
dev_resource_filter,
2660+
);
26552661
if (try display.resources.lookupOne(translation_filename, .csv, gpa)) |resource| {
26562662
const data = try sdl_load_resource(display.resources, resource, gpa);
26572663
defer gpa.free(data);
@@ -4652,7 +4658,7 @@ pub const Display = struct {
46524658
};
46534659
info("making resource bundle: {s}", .{buffer.slice()});
46544660

4655-
display.resources.save_bundle(buffer.slice(), manifest.items) catch |e| {
4661+
display.resources.save_bundle(buffer.slice(), manifest.items, .{}, "/tmp") catch |e| {
46564662
info("save resource bundle failed. {s} {any}", .{ buffer.slice(), e });
46574663
};
46584664
} else {
@@ -5531,14 +5537,14 @@ const eq = std.testing.expectEqual;
55315537
test "init catch" {
55325538
const allocator = std.testing.allocator;
55335539
// The display takes ownership of the resources object
5534-
var display = try Display.create(allocator, "test", "test", "test", "./test/repo", "test translation", 0);
5540+
var display = try Display.create(allocator, "test", "test", "test", "./test/repo", null, "test translation", 0);
55355541
defer display.destroy(allocator);
55365542
}
55375543

55385544
test "button sizing" {
55395545
const allocator = std.testing.allocator;
55405546
// The display takes ownership of the resources object
5541-
var display = try Display.create(allocator, "test", "test", "test", "./test/repo", "test translation", 0);
5547+
var display = try Display.create(allocator, "test", "test", "test", "./test/repo", null, "test translation", 0);
55425548
defer display.destroy(allocator);
55435549
_ = try display.load_font(allocator, "Roboto-Light");
55445550
try eq(1, display.fonts.items.len);
@@ -5603,7 +5609,7 @@ test "button sizing" {
56035609
test "text input sizing" {
56045610
const allocator = std.testing.allocator;
56055611
// The display takes ownership of the resources object
5606-
var display = try Display.create(allocator, "test", "test", "test", "./test/repo", "test translation", 0);
5612+
var display = try Display.create(allocator, "test", "test", "test", "./test/repo", null, "test translation", 0);
56075613
defer display.destroy(allocator);
56085614

56095615
// Add test font so we can test label layout
@@ -5751,7 +5757,7 @@ test "text input sizing" {
57515757

57525758
test "test_init" {
57535759
const allocator = std.testing.allocator;
5754-
var display = try Display.create(allocator, "test", "test", "test", "./test/repo", "test translation", 0);
5760+
var display = try Display.create(allocator, "test", "test", "test", "./test/repo", null, "test translation", 0);
57555761
defer display.destroy(allocator);
57565762
var panel = try create_panel(allocator, display, .{
57575763
.rect = .{ .width = 500, .height = 200 },

src/read_write.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ pub fn init_resource_loader(
99
allocator: Allocator,
1010
bundle_filename: []const u8,
1111
dev_repo: []const u8,
12-
) (Allocator.Error || Resources.Error || engine.Error || error{
12+
dev_repo_filter: ?fn (name: []const u8, extension: Resource.Type) bool,
13+
) (Allocator.Error || Resources.Error || engine.Error || std.fs.Dir.StatError || std.fs.File.StatError || std.fs.File.OpenError || error{
1314
ResourceReadError,
1415
Utf8ExpectedContinuation,
1516
Utf8OverlongEncoding,
@@ -51,7 +52,7 @@ pub fn init_resource_loader(
5152
// folder if it is available.
5253
if (dev_repo.len > 0) {
5354
debug("Fallback to loading repo from folder: {s}", .{dev_repo});
54-
loaded = resources.load_directory(dev_repo) catch |e| {
55+
loaded = resources.load_directory(dev_repo, dev_repo_filter) catch |e| {
5556
err("error loading repo from {s}. {any}", .{ dev_repo, e });
5657
return e;
5758
};

0 commit comments

Comments
 (0)