TextPipeline: make .init and .deinit explicit

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
Stephen Gutekanst 2024-04-28 11:10:03 -07:00 committed by Stephen Gutekanst
parent ed9137fe98
commit e0640cc948
2 changed files with 11 additions and 4 deletions

View file

@ -39,6 +39,7 @@ pub const Mod = mach.Mod(@This());
pub const global_events = .{ pub const global_events = .{
.init = .{ .handler = init }, .init = .{ .handler = init },
.deinit = .{ .handler = deinit },
.tick = .{ .handler = tick }, .tick = .{ .handler = tick },
}; };
@ -56,6 +57,12 @@ const text1: []const []const u8 = &.{
const text2: []const []const u8 = &.{"$!?😊"}; const text2: []const []const u8 = &.{"$!?😊"};
fn deinit(
text_pipeline: *gfx.TextPipeline.Mod,
) !void {
text_pipeline.send(.deinit, .{});
}
fn init( fn init(
core: *mach.Core.Mod, core: *mach.Core.Mod,
text: *gfx.Text.Mod, text: *gfx.Text.Mod,
@ -63,6 +70,8 @@ fn init(
text_style: *gfx.TextStyle.Mod, text_style: *gfx.TextStyle.Mod,
game: *Mod, game: *Mod,
) !void { ) !void {
text_pipeline.send(.init, .{});
// TODO: a better way to initialize entities with default values // TODO: a better way to initialize entities with default values
// TODO(text): most of these style options are not respected yet. // TODO(text): most of these style options are not respected yet.
const style1 = try core.newEntity(); const style1 = try core.newEntity();

View file

@ -60,11 +60,9 @@ pub const components = .{
.built = .{ .type = BuiltPipeline, .description = "internal" }, .built = .{ .type = BuiltPipeline, .description = "internal" },
}; };
pub const global_events = .{
.deinit = .{ .handler = deinit },
};
pub const local_events = .{ pub const local_events = .{
.init = .{ .handler = fn () void },
.deinit = .{ .handler = deinit },
.update = .{ .handler = update }, .update = .{ .handler = update },
.pre_render = .{ .handler = preRender }, .pre_render = .{ .handler = preRender },
.render = .{ .handler = render }, .render = .{ .handler = render },