actually rendering a table

This commit is contained in:
Tenari
2026-02-06 08:02:52 -06:00
parent 90cf7272a8
commit 067ce881e5
3 changed files with 205 additions and 2 deletions
+36 -1
View File
@@ -33,12 +33,14 @@ typedef enum ShipType {
ShipNX400,
ShipType_Count,
} ShipType;
static const char* SHIP_TYPE_STRINGS[] = {
global str SHIP_TYPE_STRINGS[] = {
"Sparrow",
"Dart",
"Hauler-Prime Z-1",
"NX-400",
};
#define SHIP_DETAIL_COUNT (8)
typedef struct ShipTemplate {
ShipType type;
u8 drive_efficiency;
@@ -77,6 +79,39 @@ global ShipTemplate SHIPS[] = {
},
};
typedef enum {
FieldTypeU8,
FieldTypeU16,
FieldTypeU32,
FieldTypeFloat,
FieldTypeString,
FieldTypeEnum,
FieldType_Count,
} FieldType;
typedef struct FieldDescriptor {
str name;
FieldType type;
size_t offset;
int width; // column width for display
str* enum_vals;
} FieldDescriptor;
// Define field metadata using offsetof
#define offsetof(st, m) ((size_t)&(((st*)0)->m))
// Field descriptors for Employee
global FieldDescriptor SHIP_FIELDS[SHIP_DETAIL_COUNT] = {
{ "Type", FieldTypeEnum, offsetof(ShipTemplate, type), 16, (str*)&SHIP_TYPE_STRINGS },
{ "Cost", FieldTypeU32, offsetof(ShipTemplate, base_cost), 8 },
{ "DriveEff", FieldTypeU8, offsetof(ShipTemplate, drive_efficiency), 8 },
{ "LifeSupp", FieldTypeU8, offsetof(ShipTemplate, life_support_efficiency), 8 },
{ "V.Cargo", FieldTypeU16, offsetof(ShipTemplate, vacuum_cargo_slots), 7 },
{ "C.Cargo", FieldTypeU16, offsetof(ShipTemplate, climate_cargo_slots), 7 },
{ "Passengers", FieldTypeU16, offsetof(ShipTemplate, passenger_berths), 10 },
{ "SmugglersHold", FieldTypeU16, offsetof(ShipTemplate, smugglers_hold_cu_m), 13 },
};
typedef struct PlayerShip {
ShipType type;
u8 drive_efficiency;