implemented gui mode view
This commit is contained in:
parent
987ee5c2d3
commit
a23921bc98
@ -71,10 +71,12 @@ pub fn build(b: *std.Build) void {
|
||||
});
|
||||
|
||||
const raylib = raylib_dep.module("raylib"); // main raylib module
|
||||
const raygui = raylib_dep.module("raygui"); // raygui module
|
||||
const raylib_artifact = raylib_dep.artifact("raylib"); // raylib c library
|
||||
|
||||
exe.linkLibrary(raylib_artifact);
|
||||
exe.root_module.addImport("raylib", raylib);
|
||||
exe.root_module.addImport("raygui", raygui);
|
||||
|
||||
// This declares intent for the executable to be installed into the
|
||||
// standard location when the user invokes the "install" step (the default
|
||||
|
@ -50,5 +50,6 @@ pub fn main() !void {
|
||||
road_manager.draw();
|
||||
area_manager.draw();
|
||||
road_manager.drawNodes();
|
||||
try road_manager.drawMode();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
const std = @import("std");
|
||||
const rl = @import("raylib");
|
||||
// const rg = @import("raygui");
|
||||
const area_str = @import("../area/areas.zig");
|
||||
const road_str = @import("road.zig");
|
||||
const road_data = @import("road-data.zig");
|
||||
@ -212,6 +213,16 @@ pub const RoadManager = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn drawMode(self: *const RoadManager) !void {
|
||||
const prefix = "Mode: ";
|
||||
const text = @tagName(self.mode); // this turns an enum into string like "normal"
|
||||
const full_text = try std.fmt.allocPrintZ(self.allocator, "{s}{s}", .{ prefix, text });
|
||||
defer self.allocator.free(full_text);
|
||||
|
||||
// draw funct
|
||||
rl.drawText(full_text, @divTrunc(globals.getScreenWidth(), 3), 50, 100, .dark_blue);
|
||||
}
|
||||
|
||||
fn getLastIndex(self: *const RoadManager) ?usize {
|
||||
if (self.roads.items.len == 0) return null;
|
||||
return self.roads.items.len - 1;
|
||||
|
@ -19,7 +19,7 @@ pub const Road = struct {
|
||||
pub fn confirmRoad(self: *Road, pos: rl.Vector2) void {
|
||||
self.end_point = pos;
|
||||
}
|
||||
|
||||
// lets make each road state carry the color with it instead of this
|
||||
pub fn setColor(self: *Road, road_state: str.RoadState) void {
|
||||
self.color = switch (road_state) {
|
||||
.valid => .black,
|
||||
|
Loading…
x
Reference in New Issue
Block a user