|
|
|
@ -122,6 +122,9 @@ fn draw_db1(state: *AppState) !void {
|
|
|
|
|
if (ds.fetch_result) |data| { |
|
|
|
|
if (data.value.object.get("departures")) |departures_raw| { |
|
|
|
|
const departures = departures_raw.array.items; |
|
|
|
|
if (departures.len == 0) { |
|
|
|
|
rl.SetWindowTitle("No Departures"); |
|
|
|
|
} |
|
|
|
|
var not_cancelled = std.ArrayList(std.json.Value).init(allocator); |
|
|
|
|
defer not_cancelled.deinit(); |
|
|
|
|
for (departures) |d| { |
|
|
|
@ -404,6 +407,7 @@ fn draw_db1(state: *AppState) !void {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
rl.SetWindowTitle("Loading..."); |
|
|
|
|
rl.DrawText(state.departure_screen_state.station_id.items.ptr, 16, 16, 32, rl.WHITE); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -464,6 +468,9 @@ fn draw_ns(state: *AppState) !void {
|
|
|
|
|
if (ds.fetch_result) |data| { |
|
|
|
|
if (data.value.object.get("departures")) |departures_raw| { |
|
|
|
|
const departures = departures_raw.array.items; |
|
|
|
|
if (departures.len == 0) { |
|
|
|
|
rl.SetWindowTitle("No Departures"); |
|
|
|
|
} |
|
|
|
|
for (departures, 0..) |d, idx| { |
|
|
|
|
const line1h = rl.MeasureTextEx(font, "00:00", station_fs, 1).y; |
|
|
|
|
const line2h = rl.MeasureTextEx(font, "Cancelled", cancel_fs, 1).y; |
|
|
|
@ -474,6 +481,12 @@ fn draw_ns(state: *AppState) !void {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const train = d.object; |
|
|
|
|
station_name_blk: { |
|
|
|
|
const station_name = std.fmt.allocPrintZ(allocator, "{s}", .{train.get("stop").?.object.get("name").?.string}) catch break :station_name_blk; |
|
|
|
|
defer allocator.free(station_name); |
|
|
|
|
rl.SetWindowTitle(station_name.ptr); |
|
|
|
|
raylib.DrawRightAlignedTextEx(font, station_name, @floatFromInt(rl.GetScreenWidth() - 4), 4, 14, 0.8, rl.WHITE); |
|
|
|
|
} |
|
|
|
|
const cancelled = blk: { |
|
|
|
|
if (train.get("cancelled")) |cancelled| { |
|
|
|
|
switch (cancelled) { |
|
|
|
@ -628,6 +641,8 @@ fn draw_ns(state: *AppState) !void {
|
|
|
|
|
y += cancelled_h + 4; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
rl.SetWindowTitle("Loading..."); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|