|
|
@ -141,12 +141,7 @@ pub fn render(state: *AppState) !void { |
|
|
|
const destination = try std.fmt.allocPrintZ(allocator, "{s}", .{first.get("direction").?.string}); |
|
|
|
const destination = try std.fmt.allocPrintZ(allocator, "{s}", .{first.get("direction").?.string}); |
|
|
|
defer allocator.free(destination); |
|
|
|
defer allocator.free(destination); |
|
|
|
var next_y = y; |
|
|
|
var next_y = y; |
|
|
|
if (state.db_font) |db_font| { |
|
|
|
next_y += @intFromFloat(raylib.DrawAndMeasureTextEx(state.font, line.ptr, 16, @floatFromInt(y), 32, 1, rl.WHITE).y); |
|
|
|
next_y += @intFromFloat(raylib.DrawAndMeasureTextEx(db_font, line.ptr, 16, @floatFromInt(y), 32, 1, rl.WHITE).y); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
rl.DrawText(line.ptr, 16, y, 32, rl.WHITE); |
|
|
|
|
|
|
|
next_y += 32; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
next_y += 16; |
|
|
|
next_y += 16; |
|
|
|
if (ds.platform.items.len == 0) blk: { |
|
|
|
if (ds.platform.items.len == 0) blk: { |
|
|
|
if (first.get("platform")) |platform_raw| { |
|
|
|
if (first.get("platform")) |platform_raw| { |
|
|
@ -154,20 +149,15 @@ pub fn render(state: *AppState) !void { |
|
|
|
.string => |p| { |
|
|
|
.string => |p| { |
|
|
|
const platform = std.fmt.allocPrintZ(allocator, "{s}", .{p}) catch break :blk; |
|
|
|
const platform = std.fmt.allocPrintZ(allocator, "{s}", .{p}) catch break :blk; |
|
|
|
defer allocator.free(platform); |
|
|
|
defer allocator.free(platform); |
|
|
|
if (state.db_font) |db_font| { |
|
|
|
raylib.DrawRightAlignedTextEx(state.font, platform.ptr, @floatFromInt(rl.GetScreenWidth() - 16), @floatFromInt(y), 40, 1, rl.WHITE); |
|
|
|
raylib.DrawRightAlignedTextEx(db_font, platform.ptr, @floatFromInt(rl.GetScreenWidth() - 16), @floatFromInt(y), 40, 1, rl.WHITE); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
raylib.DrawRightAlignedText(platform.ptr, rl.GetScreenWidth() - 16, y, 40, rl.WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
else => {}, |
|
|
|
else => {}, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
y = next_y; |
|
|
|
y = next_y; |
|
|
|
if (state.db_font) |db_font| { |
|
|
|
|
|
|
|
y += @intFromFloat(raylib.DrawAndMeasureTextEx( |
|
|
|
y += @intFromFloat(raylib.DrawAndMeasureTextEx( |
|
|
|
db_font, |
|
|
|
state.font, |
|
|
|
destination.ptr, |
|
|
|
destination.ptr, |
|
|
|
16, |
|
|
|
16, |
|
|
|
@floatFromInt(y), |
|
|
|
@floatFromInt(y), |
|
|
@ -175,10 +165,7 @@ pub fn render(state: *AppState) !void { |
|
|
|
1, |
|
|
|
1, |
|
|
|
rl.WHITE, |
|
|
|
rl.WHITE, |
|
|
|
).y); |
|
|
|
).y); |
|
|
|
} else { |
|
|
|
|
|
|
|
rl.DrawText(destination.ptr, 16, y, 56, rl.WHITE); |
|
|
|
|
|
|
|
y += 56; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
y += 16; |
|
|
|
y += 16; |
|
|
|
} |
|
|
|
} |
|
|
|
if (not_cancelled.items.len > 1) { |
|
|
|
if (not_cancelled.items.len > 1) { |
|
|
@ -189,21 +176,15 @@ pub fn render(state: *AppState) !void { |
|
|
|
var y = rl.GetScreenHeight() - (font_size + 8) * max_trains - 4; |
|
|
|
var y = rl.GetScreenHeight() - (font_size + 8) * max_trains - 4; |
|
|
|
rl.DrawRectangle(0, y, rl.GetScreenWidth(), rl.GetScreenHeight(), rl.WHITE); |
|
|
|
rl.DrawRectangle(0, y, rl.GetScreenWidth(), rl.GetScreenHeight(), rl.WHITE); |
|
|
|
y += 8; |
|
|
|
y += 8; |
|
|
|
const label_measurement_width = if (state.db_font) |db_font| @as(c_int, @intFromFloat(raylib.DrawAndMeasureTextEx( |
|
|
|
const label_measurement_width = @as(c_int, @intFromFloat(raylib.DrawAndMeasureTextEx( |
|
|
|
db_font, |
|
|
|
state.font, |
|
|
|
if (max_trains == 1) "Next train: " else "Next trains: ", |
|
|
|
if (max_trains == 1) "Next train: " else "Next trains: ", |
|
|
|
@floatFromInt(x), |
|
|
|
@floatFromInt(x), |
|
|
|
@floatFromInt(y), |
|
|
|
@floatFromInt(y), |
|
|
|
@floatFromInt(font_size), |
|
|
|
@floatFromInt(font_size), |
|
|
|
1, |
|
|
|
1, |
|
|
|
db_blue, |
|
|
|
db_blue, |
|
|
|
).x)) else raylib.DrawAndMeasureText( |
|
|
|
).x)); |
|
|
|
if (max_trains == 1) "Next train: " else "Next trains: ", |
|
|
|
|
|
|
|
x, |
|
|
|
|
|
|
|
y, |
|
|
|
|
|
|
|
font_size, |
|
|
|
|
|
|
|
db_blue, |
|
|
|
|
|
|
|
).width; |
|
|
|
|
|
|
|
x += label_measurement_width; |
|
|
|
x += label_measurement_width; |
|
|
|
|
|
|
|
|
|
|
|
// Compute line name width |
|
|
|
// Compute line name width |
|
|
@ -220,14 +201,10 @@ pub fn render(state: *AppState) !void { |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
defer allocator.free(next_train_line); |
|
|
|
defer allocator.free(next_train_line); |
|
|
|
if (state.db_font) |db_font| { |
|
|
|
|
|
|
|
line_name_width = @max( |
|
|
|
line_name_width = @max( |
|
|
|
line_name_width, |
|
|
|
line_name_width, |
|
|
|
@as(c_int, @intFromFloat(rl.MeasureTextEx(db_font, next_train_line.ptr, @floatFromInt(font_size), 1).x)), |
|
|
|
@as(c_int, @intFromFloat(rl.MeasureTextEx(state.font, next_train_line.ptr, @floatFromInt(font_size), 1).x)), |
|
|
|
); |
|
|
|
); |
|
|
|
} else { |
|
|
|
|
|
|
|
line_name_width = @max(line_name_width, rl.MeasureText(next_train_line.ptr, font_size)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
const destionation_x = x + line_name_width; |
|
|
|
const destionation_x = x + line_name_width; |
|
|
|
|
|
|
|
|
|
|
@ -251,24 +228,15 @@ pub fn render(state: *AppState) !void { |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
defer allocator.free(next_train_direction); |
|
|
|
defer allocator.free(next_train_direction); |
|
|
|
if (state.db_font) |db_font| { |
|
|
|
rl.DrawTextEx(state.font, next_train_line.ptr, .{ .x = @floatFromInt(x), .y = @floatFromInt(y) }, font_size, 1, db_blue); |
|
|
|
rl.DrawTextEx(db_font, next_train_line.ptr, .{ .x = @floatFromInt(x), .y = @floatFromInt(y) }, font_size, 1, db_blue); |
|
|
|
rl.DrawTextEx(state.font, next_train_direction.ptr, .{ .x = @floatFromInt(destionation_x), .y = @floatFromInt(y) }, font_size, 1, db_blue); |
|
|
|
rl.DrawTextEx(db_font, next_train_direction.ptr, .{ .x = @floatFromInt(destionation_x), .y = @floatFromInt(y) }, font_size, 1, db_blue); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
rl.DrawText(next_train_line.ptr, x, y, font_size, db_blue); |
|
|
|
|
|
|
|
rl.DrawText(next_train_direction.ptr, destionation_x, y, font_size, db_blue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (ds.platform.items.len == 0) blk: { |
|
|
|
if (ds.platform.items.len == 0) blk: { |
|
|
|
if (second.get("platform")) |platform_raw| { |
|
|
|
if (second.get("platform")) |platform_raw| { |
|
|
|
switch (platform_raw) { |
|
|
|
switch (platform_raw) { |
|
|
|
.string => |p| { |
|
|
|
.string => |p| { |
|
|
|
const platform = std.fmt.allocPrintZ(allocator, "{s}", .{p}) catch break :blk; |
|
|
|
const platform = std.fmt.allocPrintZ(allocator, "{s}", .{p}) catch break :blk; |
|
|
|
defer allocator.free(platform); |
|
|
|
defer allocator.free(platform); |
|
|
|
if (state.db_font) |db_font| { |
|
|
|
raylib.DrawRightAlignedTextEx(state.font, platform.ptr, @floatFromInt(rl.GetScreenWidth() - 16), @floatFromInt(y), @floatFromInt(font_size), 1, db_blue); |
|
|
|
raylib.DrawRightAlignedTextEx(db_font, platform.ptr, @floatFromInt(rl.GetScreenWidth() - 16), @floatFromInt(y), @floatFromInt(font_size), 1, db_blue); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
raylib.DrawRightAlignedText(platform.ptr, rl.GetScreenWidth() - 16, y, font_size, db_blue); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
else => {}, |
|
|
|
else => {}, |
|
|
|
} |
|
|
|
} |
|
|
|