|
|
@ -75,6 +75,8 @@ fn fetchThread(state: *AppState) !void { |
|
|
|
std.debug.print("[departure/fetchThread] JSON parse error: {}\n", .{err}); |
|
|
|
std.debug.print("[departure/fetchThread] JSON parse error: {}\n", .{err}); |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
state.departure_screen_state.mutex.lock(); |
|
|
|
|
|
|
|
defer state.departure_screen_state.mutex.unlock(); |
|
|
|
if (state.departure_screen_state.fetch_result) |old_result| { |
|
|
|
if (state.departure_screen_state.fetch_result) |old_result| { |
|
|
|
old_result.deinit(); |
|
|
|
old_result.deinit(); |
|
|
|
} |
|
|
|
} |
|
|
@ -532,7 +534,9 @@ pub fn render(state: *AppState) !void { |
|
|
|
rl.KEY_MINUS, rl.KEY_KP_SUBTRACT => { |
|
|
|
rl.KEY_MINUS, rl.KEY_KP_SUBTRACT => { |
|
|
|
ds.max_next_trains = @max(1, ds.max_next_trains - 1); |
|
|
|
ds.max_next_trains = @max(1, ds.max_next_trains - 1); |
|
|
|
}, |
|
|
|
}, |
|
|
|
rl.KEY_EQUAL, rl.KEY_KP_EQUAL => { |
|
|
|
rl.KEY_EQUAL, rl.KEY_KP_ADD => { |
|
|
|
|
|
|
|
ds.mutex.lock(); |
|
|
|
|
|
|
|
defer ds.mutex.unlock(); |
|
|
|
ds.max_next_trains = @min(ds.max_next_trains + 1, if (ds.fetch_result) |fr| @as(c_int, @intCast(fr.value.object.get("departures").?.array.items.len)) else 5); |
|
|
|
ds.max_next_trains = @min(ds.max_next_trains + 1, if (ds.fetch_result) |fr| @as(c_int, @intCast(fr.value.object.get("departures").?.array.items.len)) else 5); |
|
|
|
}, |
|
|
|
}, |
|
|
|
rl.KEY_T => { |
|
|
|
rl.KEY_T => { |
|
|
@ -551,10 +555,14 @@ pub fn render(state: *AppState) !void { |
|
|
|
rl.BeginDrawing(); |
|
|
|
rl.BeginDrawing(); |
|
|
|
defer rl.EndDrawing(); |
|
|
|
defer rl.EndDrawing(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ds.mutex.lock(); |
|
|
|
|
|
|
|
defer ds.mutex.unlock(); |
|
|
|
switch (ds.render_style) { |
|
|
|
switch (ds.render_style) { |
|
|
|
.db1 => try draw_db1(state), |
|
|
|
.db1 => try draw_db1(state), |
|
|
|
.ns => try draw_ns(state), |
|
|
|
.ns => try draw_ns(state), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
state.close_app = rl.WindowShouldClose(); |
|
|
|
state.close_app = rl.WindowShouldClose(); |
|
|
|
} |
|
|
|
} |
|
|
|