Compare commits
No commits in common. "61bcf53b33137956de100c2e0b29f781ac033e20" and "cf9f72459dd04cc14af6d62ed8ae3cbc440c318a" have entirely different histories.
61bcf53b33
...
cf9f72459d
6 changed files with 11 additions and 40 deletions
26
build.zig
26
build.zig
|
@ -31,11 +31,7 @@ pub fn build(b: *std.Build) void {
|
||||||
// exe.linkSystemLibrary("raylib");
|
// exe.linkSystemLibrary("raylib");
|
||||||
exe.linkSystemLibrary("curl");
|
exe.linkSystemLibrary("curl");
|
||||||
exe.addObjectFile(.{
|
exe.addObjectFile(.{
|
||||||
.cwd_relative = switch (target.result.os.tag) {
|
.cwd_relative = "/opt/homebrew/Cellar/raylib/5.0/lib/libraylib.a",
|
||||||
.macos => "/opt/homebrew/Cellar/raylib/5.0/lib/libraylib.a",
|
|
||||||
.linux => "./libraylib.a",
|
|
||||||
else => @panic("Unsupported platform"),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
// exe.addObjectFile(.{
|
// exe.addObjectFile(.{
|
||||||
// .cwd_relative = "/opt/homebrew/Cellar/curl/8.5.0/lib/libcurl.a",
|
// .cwd_relative = "/opt/homebrew/Cellar/curl/8.5.0/lib/libcurl.a",
|
||||||
|
@ -44,20 +40,12 @@ pub fn build(b: *std.Build) void {
|
||||||
.cwd_relative = "/opt/homebrew/Cellar/raylib/5.0/include",
|
.cwd_relative = "/opt/homebrew/Cellar/raylib/5.0/include",
|
||||||
});
|
});
|
||||||
// Raylib dependencies
|
// Raylib dependencies
|
||||||
switch (target.result.os.tag) {
|
exe.linkFramework("Foundation");
|
||||||
.macos => {
|
exe.linkFramework("CoreVideo");
|
||||||
exe.linkFramework("Foundation");
|
exe.linkFramework("IOKit");
|
||||||
exe.linkFramework("CoreVideo");
|
exe.linkFramework("Cocoa");
|
||||||
exe.linkFramework("IOKit");
|
exe.linkFramework("GLUT");
|
||||||
exe.linkFramework("Cocoa");
|
exe.linkFramework("OpenGL");
|
||||||
exe.linkFramework("GLUT");
|
|
||||||
exe.linkFramework("OpenGL");
|
|
||||||
},
|
|
||||||
.linux => {
|
|
||||||
exe.linkSystemLibrary("c");
|
|
||||||
},
|
|
||||||
else => @panic("Unsupported platform"),
|
|
||||||
}
|
|
||||||
|
|
||||||
// This declares intent for the executable to be installed into the
|
// This declares intent for the executable to be installed into the
|
||||||
// standard location when the user invokes the "install" step (the default
|
// standard location when the user invokes the "install" step (the default
|
||||||
|
|
|
@ -4,7 +4,7 @@ const rl = raylib.rl;
|
||||||
const AppState = @import("state.zig");
|
const AppState = @import("state.zig");
|
||||||
const Curl = @import("curl.zig");
|
const Curl = @import("curl.zig");
|
||||||
const C = @cImport({
|
const C = @cImport({
|
||||||
@cDefine("_XOPEN_SOURCE", "");
|
@cDefine("_XOPEN_SOURE", "");
|
||||||
@cInclude("time.h");
|
@cInclude("time.h");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,8 +65,6 @@ fn fetchThread(state: *AppState) !void {
|
||||||
defer result.deinit();
|
defer result.deinit();
|
||||||
_ = curl.setopt(.write_function, Curl.Utils.array_list_append);
|
_ = curl.setopt(.write_function, Curl.Utils.array_list_append);
|
||||||
_ = curl.setopt(.write_data, &result);
|
_ = curl.setopt(.write_data, &result);
|
||||||
_ = curl.setopt(.low_speed_limit, @as(c_long, 128));
|
|
||||||
_ = curl.setopt(.low_speed_time, @as(c_long, 5));
|
|
||||||
|
|
||||||
const code = curl.perform();
|
const code = curl.perform();
|
||||||
std.debug.print("[departure/fetchThread] cURL Code: {}\n", .{code});
|
std.debug.print("[departure/fetchThread] cURL Code: {}\n", .{code});
|
||||||
|
@ -436,7 +434,7 @@ fn draw_ns(state: *AppState) !void {
|
||||||
const header_height = rl.MeasureTextEx(font, "Vertrek", header_fs, 1).y;
|
const header_height = rl.MeasureTextEx(font, "Vertrek", header_fs, 1).y;
|
||||||
rl.DrawRectangle(0, 0, rl.GetScreenWidth(), 4 + @as(c_int, @intFromFloat(header_height)) + 4, ns_bg2);
|
rl.DrawRectangle(0, 0, rl.GetScreenWidth(), 4 + @as(c_int, @intFromFloat(header_height)) + 4, ns_bg2);
|
||||||
raylib.DrawTextEx(font, if (language == 0) "Vertrek" else "Depart", 8, 4, header_fs, 1, ns_fg1);
|
raylib.DrawTextEx(font, if (language == 0) "Vertrek" else "Depart", 8, 4, header_fs, 1, ns_fg1);
|
||||||
raylib.DrawTextEx(font, if (language == 0) "Naar/Opmerking" else "To/Remarks", 8 + col1w + 8, 4, header_fs, 1, ns_fg1);
|
raylib.DrawTextEx(font, if (language == 0) "Naar/Opmerking" else "To/Via", 8 + col1w + 8, 4, header_fs, 1, ns_fg1);
|
||||||
raylib.DrawTextEx(font, if (language == 0) "Spoor" else "Platform", @floatFromInt(rl.GetScreenWidth() - 200), 4, header_fs, 1, ns_fg1);
|
raylib.DrawTextEx(font, if (language == 0) "Spoor" else "Platform", @floatFromInt(rl.GetScreenWidth() - 200), 4, header_fs, 1, ns_fg1);
|
||||||
|
|
||||||
var y = header_height + 8 + 2;
|
var y = header_height + 8 + 2;
|
||||||
|
|
12
src/home.zig
12
src/home.zig
|
@ -44,8 +44,6 @@ fn fetchThread(state: *AppState) !void {
|
||||||
defer result.deinit();
|
defer result.deinit();
|
||||||
_ = curl.setopt(.write_function, Curl.Utils.array_list_append);
|
_ = curl.setopt(.write_function, Curl.Utils.array_list_append);
|
||||||
_ = curl.setopt(.write_data, &result);
|
_ = curl.setopt(.write_data, &result);
|
||||||
_ = curl.setopt(.low_speed_limit, @as(c_long, 128));
|
|
||||||
_ = curl.setopt(.low_speed_time, @as(c_long, 5));
|
|
||||||
|
|
||||||
const code = curl.perform();
|
const code = curl.perform();
|
||||||
std.debug.print("[home/fetchThread] cURL Code: {}\n", .{code});
|
std.debug.print("[home/fetchThread] cURL Code: {}\n", .{code});
|
||||||
|
@ -72,8 +70,6 @@ fn fetchThread(state: *AppState) !void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
state.home_screen_state.mutex.lock();
|
|
||||||
defer state.home_screen_state.mutex.unlock();
|
|
||||||
if (state.home_screen_state.suggestions.len > 0) {
|
if (state.home_screen_state.suggestions.len > 0) {
|
||||||
for (state.home_screen_state.suggestions) |suggestion| {
|
for (state.home_screen_state.suggestions) |suggestion| {
|
||||||
allocator.free(suggestion.id);
|
allocator.free(suggestion.id);
|
||||||
|
@ -96,14 +92,8 @@ pub fn render(state: *AppState) !void {
|
||||||
}
|
}
|
||||||
|
|
||||||
while (raylib.GetCharPressed()) |char| {
|
while (raylib.GetCharPressed()) |char| {
|
||||||
if (hs.station_name.items.len < hs.station_name_max_len) {
|
hs.station_name.appendAssumeCapacity(@intCast(char));
|
||||||
hs.station_name.appendAssumeCapacity(@intCast(char));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
state.home_screen_state.mutex.lock();
|
|
||||||
defer state.home_screen_state.mutex.unlock();
|
|
||||||
|
|
||||||
while (raylib.GetKeyPressed()) |key| {
|
while (raylib.GetKeyPressed()) |key| {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
rl.KEY_BACKSPACE => {
|
rl.KEY_BACKSPACE => {
|
||||||
|
|
|
@ -5,8 +5,6 @@ const home = @import("home.zig");
|
||||||
const departure = @import("departure.zig");
|
const departure = @import("departure.zig");
|
||||||
const AppState = @import("state.zig");
|
const AppState = @import("state.zig");
|
||||||
|
|
||||||
const noto = @embedFile("./noto.ttf");
|
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
|
||||||
const allocator = gpa.allocator();
|
const allocator = gpa.allocator();
|
||||||
|
@ -27,12 +25,11 @@ pub fn main() !void {
|
||||||
var station_id_buffer: [10]u8 = .{0} ** 10;
|
var station_id_buffer: [10]u8 = .{0} ** 10;
|
||||||
var appState = AppState{
|
var appState = AppState{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.font = rl.LoadFontFromMemory(".ttf", noto, noto.len, 64, cp, cp_cnt),
|
.font = rl.LoadFontEx("./noto.ttf", 64, cp, cp_cnt),
|
||||||
.db_font = raylib.LoadFontEx("./private/db.ttf", 64, cp, cp_cnt),
|
.db_font = raylib.LoadFontEx("./private/db.ttf", 64, cp, cp_cnt),
|
||||||
.ns_font = raylib.LoadFontEx("./private/ns.ttf", 64, cp, cp_cnt),
|
.ns_font = raylib.LoadFontEx("./private/ns.ttf", 64, cp, cp_cnt),
|
||||||
.home_screen_state = .{
|
.home_screen_state = .{
|
||||||
.station_name = std.ArrayListUnmanaged(u8).initBuffer(&station_name_buffer),
|
.station_name = std.ArrayListUnmanaged(u8).initBuffer(&station_name_buffer),
|
||||||
.station_name_max_len = station_name_buffer.len - 1,
|
|
||||||
},
|
},
|
||||||
.departure_screen_state = .{
|
.departure_screen_state = .{
|
||||||
.platform = std.ArrayListUnmanaged(u8).initBuffer(&platform_buffer),
|
.platform = std.ArrayListUnmanaged(u8).initBuffer(&platform_buffer),
|
||||||
|
|
|
@ -13,9 +13,7 @@ pub const HSSuggestion = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const HomeScreenState = struct {
|
pub const HomeScreenState = struct {
|
||||||
mutex: std.Thread.Mutex = .{},
|
|
||||||
station_name: std.ArrayListUnmanaged(u8),
|
station_name: std.ArrayListUnmanaged(u8),
|
||||||
station_name_max_len: usize,
|
|
||||||
fetch_thread: ?std.Thread = null,
|
fetch_thread: ?std.Thread = null,
|
||||||
suggestions: []HSSuggestion = &.{},
|
suggestions: []HSSuggestion = &.{},
|
||||||
selection_idx: i8 = 0,
|
selection_idx: i8 = 0,
|
||||||
|
|
Loading…
Add table
Reference in a new issue