Adjust Doom animation speed through config.ini

This commit is contained in:
0xNiffin 2024-07-22 16:18:12 +01:00
parent 1d7a001a0b
commit 231ec3adac
4 changed files with 15 additions and 7 deletions

View File

@ -4,6 +4,9 @@
# matrix -> CMatrix
animation = none
# Adjust doom animation speed by adding some delay (in milliseconds) when it draws the flames.
doom_delay = 0
# Format string for clock in top right corner (see strftime specification). Example: %c
clock = null

View File

@ -28,8 +28,9 @@ pub const FIRE = [_]termbox.tb_cell{
allocator: Allocator,
terminal_buffer: *TerminalBuffer,
buffer: []u8,
delay: u64,
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer) !Doom {
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer, delay: u64) !Doom {
const buffer = try allocator.alloc(u8, terminal_buffer.width * terminal_buffer.height);
initBuffer(buffer, terminal_buffer.width);
@ -37,6 +38,7 @@ pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer) !Doom {
.allocator = allocator,
.terminal_buffer = terminal_buffer,
.buffer = buffer,
.delay = delay,
};
}
@ -72,6 +74,8 @@ pub fn draw(self: Doom) void {
self.terminal_buffer.buffer[source] = FIRE[buffer_source];
}
}
// Delay related code
std.time.sleep(std.time.ns_per_ms * self.delay);
}
fn initBuffer(buffer: []u8, width: u64) void {

View File

@ -11,12 +11,17 @@ bigclock: bool = false,
blank_box: bool = true,
border_fg: u8 = 8,
box_title: ?[]const u8 = null,
brightness_down_key: []const u8 = "F5",
brightness_up_key: []const u8 = "F6",
brightnessctl: []const u8 = "/usr/bin/brightnessctl",
brightness_change: []const u8 = "10",
clear_password: bool = false,
clock: ?[:0]const u8 = null,
cmatrix_fg: u8 = 3,
console_dev: [:0]const u8 = "/dev/console",
default_input: Input = .login,
doom_delay: u64 = 0,
fg: u8 = 8,
cmatrix_fg: u8 = 3,
hide_borders: bool = false,
hide_key_hints: bool = false,
initial_info_text: ?[]const u8 = null,
@ -52,7 +57,3 @@ xinitrc: ?[]const u8 = "~/.xinitrc",
x_cmd_setup: []const u8 = build_options.data_directory ++ "/xsetup.sh",
xauth_cmd: []const u8 = "/usr/bin/xauth",
xsessions: []const u8 = "/usr/share/xsessions",
brightness_down_key: []const u8 = "F5",
brightness_up_key: []const u8 = "F6",
brightnessctl: []const u8 = "/usr/bin/brightnessctl",
brightness_change: []const u8 = "10",

View File

@ -229,7 +229,7 @@ pub fn main() !void {
switch (config.animation) {
.none => {},
.doom => doom = try Doom.init(allocator, &buffer),
.doom => doom = try Doom.init(allocator, &buffer, config.doom_delay),
.matrix => matrix = try Matrix.init(allocator, &buffer, config.cmatrix_fg),
}
defer {