{Core,examples}: set window title via component
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
79dccb4d73
commit
68677b3448
5 changed files with 104 additions and 19 deletions
|
|
@ -51,7 +51,7 @@ fn init(game: *Mod, core: *mach.Core.Mod) !void {
|
|||
.title_timer = try mach.Timer.start(),
|
||||
.pipeline = pipeline,
|
||||
});
|
||||
try updateWindowTitle();
|
||||
try updateWindowTitle(core);
|
||||
}
|
||||
|
||||
pub fn deinit(game: *Mod) void {
|
||||
|
|
@ -109,13 +109,19 @@ fn tick(core: *mach.Core.Mod, game: *Mod) !void {
|
|||
// update the window title every second
|
||||
if (game.state().title_timer.read() >= 1.0) {
|
||||
game.state().title_timer.reset();
|
||||
try updateWindowTitle();
|
||||
try updateWindowTitle(core);
|
||||
}
|
||||
}
|
||||
|
||||
fn updateWindowTitle() !void {
|
||||
try mach.core.printTitle("mach.Core - custom entrypoint [ {d}fps ] [ Input {d}hz ]", .{
|
||||
mach.core.frameRate(),
|
||||
mach.core.inputRate(),
|
||||
});
|
||||
fn updateWindowTitle(core: *mach.Core.Mod) !void {
|
||||
try mach.Core.printTitle(
|
||||
core,
|
||||
core.state().main_window,
|
||||
"core-custom-entrypoint [ {d}fps ] [ Input {d}hz ]",
|
||||
.{
|
||||
mach.core.frameRate(),
|
||||
mach.core.inputRate(),
|
||||
},
|
||||
);
|
||||
core.send(.update, .{});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue