Add window title
This commit is contained in:
parent
806b347b2e
commit
c96fb7f806
2 changed files with 17 additions and 0 deletions
|
@ -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...");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,8 @@ fn fetchThread(state: *AppState) !void {
|
|||
}
|
||||
|
||||
pub fn render(state: *AppState) !void {
|
||||
rl.SetWindowTitle("Search Station");
|
||||
|
||||
var hs = &state.home_screen_state;
|
||||
|
||||
if (hs.fetch_thread == null) {
|
||||
|
|
Loading…
Add table
Reference in a new issue