mirror of
https://github.com/fairyglade/ly.git
synced 2026-03-24 17:26:04 +00:00
Add Widget.calculateTimeout function
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -20,6 +20,7 @@ allocator: Allocator,
|
||||
terminal_buffer: *TerminalBuffer,
|
||||
animate: *bool,
|
||||
timeout_sec: u12,
|
||||
frame_delay: u16,
|
||||
buffer: []u8,
|
||||
height: u8,
|
||||
spread: u8,
|
||||
@@ -35,6 +36,7 @@ pub fn init(
|
||||
fire_spread: u8,
|
||||
animate: *bool,
|
||||
timeout_sec: u12,
|
||||
frame_delay: u16,
|
||||
) !Doom {
|
||||
const buffer = try allocator.alloc(u8, terminal_buffer.width * terminal_buffer.height);
|
||||
initBuffer(buffer, terminal_buffer.width);
|
||||
@@ -62,6 +64,7 @@ pub fn init(
|
||||
.terminal_buffer = terminal_buffer,
|
||||
.animate = animate,
|
||||
.timeout_sec = timeout_sec,
|
||||
.frame_delay = frame_delay,
|
||||
.buffer = buffer,
|
||||
.height = @min(HEIGHT_MAX, fire_height),
|
||||
.spread = @min(SPREAD_MAX, fire_spread),
|
||||
@@ -78,6 +81,7 @@ pub fn widget(self: *Doom) Widget {
|
||||
draw,
|
||||
update,
|
||||
null,
|
||||
calculateTimeout,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -147,3 +151,7 @@ fn update(self: *Doom, _: *anyopaque) !void {
|
||||
self.animate.* = false;
|
||||
}
|
||||
}
|
||||
|
||||
fn calculateTimeout(self: *Doom, _: *anyopaque) !?usize {
|
||||
return self.frame_delay;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user