mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[ecs] Move href_comp into hierarchy_t
This means that the component id used for hierarchy references must be passed to Hierarchy_New and Hierarchy_Copy, but does all an entity to have more than one hierarchy, which is useful for canvases (hierarchies of views) in the 3d world (the canvas root would have a 3d hierarchy reference and a 2d (view) hierarchy reference).
This commit is contained in:
parent
cb45fe7034
commit
bb677a1a7c
24 changed files with 63 additions and 69 deletions
|
@ -73,7 +73,6 @@ typedef struct ecs_registry_s {
|
||||||
const component_t *components;
|
const component_t *components;
|
||||||
ecs_pool_t *comp_pools;
|
ecs_pool_t *comp_pools;
|
||||||
uint32_t num_components;
|
uint32_t num_components;
|
||||||
uint32_t href_comp;//FIXME find a better way
|
|
||||||
PR_RESMAP (hierarchy_t) hierarchies;//FIXME find a better way
|
PR_RESMAP (hierarchy_t) hierarchies;//FIXME find a better way
|
||||||
} ecs_registry_t;
|
} ecs_registry_t;
|
||||||
|
|
||||||
|
|
|
@ -60,12 +60,13 @@ typedef struct hierarchy_s {
|
||||||
uint32_t *parentIndex;
|
uint32_t *parentIndex;
|
||||||
const hierarchy_type_t *type;
|
const hierarchy_type_t *type;
|
||||||
void **components;
|
void **components;
|
||||||
|
uint32_t href_comp;
|
||||||
} hierarchy_t;
|
} hierarchy_t;
|
||||||
|
|
||||||
hierarchy_t *Hierarchy_New (struct ecs_registry_s *reg,
|
hierarchy_t *Hierarchy_New (struct ecs_registry_s *reg, uint32_t href_comp,
|
||||||
const hierarchy_type_t *type, int createRoot);
|
const hierarchy_type_t *type, int createRoot);
|
||||||
void Hierarchy_Reserve (hierarchy_t *hierarchy, uint32_t count);
|
void Hierarchy_Reserve (hierarchy_t *hierarchy, uint32_t count);
|
||||||
hierarchy_t *Hierarchy_Copy (struct ecs_registry_s *reg,
|
hierarchy_t *Hierarchy_Copy (struct ecs_registry_s *reg, uint32_t href_comp,
|
||||||
const hierarchy_t *src);
|
const hierarchy_t *src);
|
||||||
void Hierarchy_Delete (hierarchy_t *hierarchy);
|
void Hierarchy_Delete (hierarchy_t *hierarchy);
|
||||||
|
|
||||||
|
|
|
@ -52,11 +52,12 @@ typedef struct passage_s {
|
||||||
const char *text; ///< Not owned by passage
|
const char *text; ///< Not owned by passage
|
||||||
|
|
||||||
struct ecs_registry_s *reg; ///< Owning ECS registry
|
struct ecs_registry_s *reg; ///< Owning ECS registry
|
||||||
|
uint32_t href_comp; ///< Component for passage hierarcy reference
|
||||||
struct hierarchy_s *hierarchy; ///< hierarchy of text objects
|
struct hierarchy_s *hierarchy; ///< hierarchy of text objects
|
||||||
} passage_t;
|
} passage_t;
|
||||||
|
|
||||||
void Passage_ParseText (passage_t *passage, const char *text);
|
void Passage_ParseText (passage_t *passage, const char *text);
|
||||||
passage_t *Passage_New (struct ecs_registry_s *reg);
|
passage_t *Passage_New (struct ecs_registry_s *reg, uint32_t href_comp);
|
||||||
void Passage_Delete (passage_t *passage);
|
void Passage_Delete (passage_t *passage);
|
||||||
int Passage_IsSpace (const char *text) __attribute__((pure));
|
int Passage_IsSpace (const char *text) __attribute__((pure));
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,7 @@ typedef void (*view_move_f) (view_t view, view_pos_t abs);
|
||||||
|
|
||||||
#define VIEWINLINE GNU89INLINE inline
|
#define VIEWINLINE GNU89INLINE inline
|
||||||
|
|
||||||
view_t View_New (ecs_registry_t *reg, view_t parent);
|
view_t View_New (ecs_registry_t *reg, uint32_t href_comp, view_t parent);
|
||||||
VIEWINLINE void View_Delete (view_t view);
|
VIEWINLINE void View_Delete (view_t view);
|
||||||
void View_SetParent (view_t view, view_t parent);
|
void View_SetParent (view_t view, view_t parent);
|
||||||
void View_UpdateHierarchy (view_t view);
|
void View_UpdateHierarchy (view_t view);
|
||||||
|
|
|
@ -171,7 +171,7 @@ CL_Init_Screen (void)
|
||||||
|
|
||||||
HUD_Init ();
|
HUD_Init ();
|
||||||
|
|
||||||
cl_screen_view = View_New (hud_registry, nullview);
|
cl_screen_view = View_New (hud_registry, hud_href, nullview);
|
||||||
con_module->data->console->screen_view = &cl_screen_view;
|
con_module->data->console->screen_view = &cl_screen_view;
|
||||||
|
|
||||||
View_SetPos (cl_screen_view, 0, 0);
|
View_SetPos (cl_screen_view, 0, 0);
|
||||||
|
@ -180,7 +180,7 @@ CL_Init_Screen (void)
|
||||||
View_SetVisible (cl_screen_view, 1);
|
View_SetVisible (cl_screen_view, 1);
|
||||||
|
|
||||||
pic = r_funcs->Draw_PicFromWad ("ram");
|
pic = r_funcs->Draw_PicFromWad ("ram");
|
||||||
ram_view = View_New (hud_registry, cl_screen_view);
|
ram_view = View_New (hud_registry, hud_href, cl_screen_view);
|
||||||
View_SetPos (ram_view, 32, 0);
|
View_SetPos (ram_view, 32, 0);
|
||||||
View_SetLen (ram_view, pic->width, pic->height);
|
View_SetLen (ram_view, pic->width, pic->height);
|
||||||
View_SetGravity (ram_view, grav_northwest);
|
View_SetGravity (ram_view, grav_northwest);
|
||||||
|
@ -188,7 +188,7 @@ CL_Init_Screen (void)
|
||||||
View_SetVisible (ram_view, 0);
|
View_SetVisible (ram_view, 0);
|
||||||
|
|
||||||
pic = r_funcs->Draw_PicFromWad ("turtle");
|
pic = r_funcs->Draw_PicFromWad ("turtle");
|
||||||
turtle_view = View_New (hud_registry, cl_screen_view);
|
turtle_view = View_New (hud_registry, hud_href, cl_screen_view);
|
||||||
View_SetPos (turtle_view, 32, 0);
|
View_SetPos (turtle_view, 32, 0);
|
||||||
View_SetLen (turtle_view, pic->width, pic->height);
|
View_SetLen (turtle_view, pic->width, pic->height);
|
||||||
View_SetGravity (turtle_view, grav_northwest);
|
View_SetGravity (turtle_view, grav_northwest);
|
||||||
|
@ -200,14 +200,14 @@ CL_Init_Screen (void)
|
||||||
Cvar_Register (&scr_showturtle_cvar, 0, 0);
|
Cvar_Register (&scr_showturtle_cvar, 0, 0);
|
||||||
|
|
||||||
pic = r_funcs->Draw_PicFromWad ("net");
|
pic = r_funcs->Draw_PicFromWad ("net");
|
||||||
net_view = View_New (hud_registry, cl_screen_view);
|
net_view = View_New (hud_registry, hud_href, cl_screen_view);
|
||||||
View_SetPos (net_view, 64, 0);
|
View_SetPos (net_view, 64, 0);
|
||||||
View_SetLen (net_view, pic->width, pic->height);
|
View_SetLen (net_view, pic->width, pic->height);
|
||||||
View_SetGravity (net_view, grav_northwest);
|
View_SetGravity (net_view, grav_northwest);
|
||||||
Ent_SetComponent (net_view.id, hud_pic, net_view.reg, &pic);
|
Ent_SetComponent (net_view.id, hud_pic, net_view.reg, &pic);
|
||||||
View_SetVisible (net_view, 0);
|
View_SetVisible (net_view, 0);
|
||||||
|
|
||||||
timegraph_view = View_New (hud_registry, cl_screen_view);
|
timegraph_view = View_New (hud_registry, hud_href, cl_screen_view);
|
||||||
View_SetPos (timegraph_view, 0, 0);
|
View_SetPos (timegraph_view, 0, 0);
|
||||||
View_SetLen (timegraph_view, r_data->vid->width, 100);
|
View_SetLen (timegraph_view, r_data->vid->width, 100);
|
||||||
View_SetGravity (timegraph_view, grav_southwest);
|
View_SetGravity (timegraph_view, grav_southwest);
|
||||||
|
@ -215,7 +215,7 @@ CL_Init_Screen (void)
|
||||||
Ent_SetComponent (timegraph_view.id, hud_func, timegraph_view.reg, &rtg);
|
Ent_SetComponent (timegraph_view.id, hud_func, timegraph_view.reg, &rtg);
|
||||||
View_SetVisible (timegraph_view, r_timegraph);
|
View_SetVisible (timegraph_view, r_timegraph);
|
||||||
|
|
||||||
zgraph_view = View_New (hud_registry, cl_screen_view);
|
zgraph_view = View_New (hud_registry, hud_href, cl_screen_view);
|
||||||
View_SetPos (zgraph_view, 0, 0);
|
View_SetPos (zgraph_view, 0, 0);
|
||||||
View_SetLen (zgraph_view, r_data->vid->width, 100);
|
View_SetLen (zgraph_view, r_data->vid->width, 100);
|
||||||
View_SetGravity (zgraph_view, grav_southwest);
|
View_SetGravity (zgraph_view, grav_southwest);
|
||||||
|
@ -225,7 +225,7 @@ CL_Init_Screen (void)
|
||||||
|
|
||||||
const char *name = "gfx/loading.lmp";
|
const char *name = "gfx/loading.lmp";
|
||||||
pic = r_funcs->Draw_CachePic (name, 1);
|
pic = r_funcs->Draw_CachePic (name, 1);
|
||||||
loading_view = View_New (hud_registry, cl_screen_view);
|
loading_view = View_New (hud_registry, hud_href, cl_screen_view);
|
||||||
View_SetPos (loading_view, 0, -24);
|
View_SetPos (loading_view, 0, -24);
|
||||||
View_SetLen (loading_view, pic->width, pic->height);
|
View_SetLen (loading_view, pic->width, pic->height);
|
||||||
View_SetGravity (loading_view, grav_center);
|
View_SetGravity (loading_view, grav_center);
|
||||||
|
@ -234,7 +234,7 @@ CL_Init_Screen (void)
|
||||||
|
|
||||||
name = "gfx/pause.lmp";
|
name = "gfx/pause.lmp";
|
||||||
pic = r_funcs->Draw_CachePic (name, 1);
|
pic = r_funcs->Draw_CachePic (name, 1);
|
||||||
pause_view = View_New (hud_registry, cl_screen_view);
|
pause_view = View_New (hud_registry, hud_href, cl_screen_view);
|
||||||
View_SetPos (pause_view, 0, -24);
|
View_SetPos (pause_view, 0, -24);
|
||||||
View_SetLen (pause_view, pic->width, pic->height);
|
View_SetLen (pause_view, pic->width, pic->height);
|
||||||
View_SetGravity (pause_view, grav_center);
|
View_SetGravity (pause_view, grav_center);
|
||||||
|
|
|
@ -266,7 +266,6 @@ HUD_Init (void)
|
||||||
{
|
{
|
||||||
hud_registry = ECS_NewRegistry ();
|
hud_registry = ECS_NewRegistry ();
|
||||||
ECS_RegisterComponents (hud_registry, hud_components, hud_comp_count);
|
ECS_RegisterComponents (hud_registry, hud_components, hud_comp_count);
|
||||||
hud_registry->href_comp = hud_href;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -254,7 +254,7 @@ static draw_charbuffer_t *solo_name;
|
||||||
static view_t
|
static view_t
|
||||||
sbar_view (int x, int y, int w, int h, grav_t gravity, view_t parent)
|
sbar_view (int x, int y, int w, int h, grav_t gravity, view_t parent)
|
||||||
{
|
{
|
||||||
view_t view = View_New (hud_registry, parent);
|
view_t view = View_New (hud_registry, hud_href, parent);
|
||||||
View_SetPos (view, x, y);
|
View_SetPos (view, x, y);
|
||||||
View_SetLen (view, w, h);
|
View_SetLen (view, w, h);
|
||||||
View_SetGravity (view, gravity);
|
View_SetGravity (view, gravity);
|
||||||
|
|
|
@ -1023,7 +1023,6 @@ C_Init (void)
|
||||||
{
|
{
|
||||||
client_reg = ECS_NewRegistry ();
|
client_reg = ECS_NewRegistry ();
|
||||||
ECS_RegisterComponents (client_reg, client_components, client_comp_count);
|
ECS_RegisterComponents (client_reg, client_components, client_comp_count);
|
||||||
client_reg->href_comp = client_href;
|
|
||||||
|
|
||||||
#ifdef __QNXNTO__
|
#ifdef __QNXNTO__
|
||||||
setlocale (LC_ALL, "C-TRADITIONAL");
|
setlocale (LC_ALL, "C-TRADITIONAL");
|
||||||
|
@ -1044,14 +1043,14 @@ C_Init (void)
|
||||||
con_debuglog = COM_CheckParm ("-condebug");
|
con_debuglog = COM_CheckParm ("-condebug");
|
||||||
|
|
||||||
// The console will get resized, so assume initial size is 320x200
|
// The console will get resized, so assume initial size is 320x200
|
||||||
screen_view = View_New (client_reg, nullview);
|
screen_view = View_New (client_reg, client_href, nullview);
|
||||||
console_view = View_New (client_reg, screen_view);
|
console_view = View_New (client_reg, client_href, screen_view);
|
||||||
buffer_view = View_New (client_reg, console_view);
|
buffer_view = View_New (client_reg, client_href, console_view);
|
||||||
command_view = View_New (client_reg, console_view);
|
command_view = View_New (client_reg, client_href, console_view);
|
||||||
download_view = View_New (client_reg, console_view);
|
download_view = View_New (client_reg, client_href, console_view);
|
||||||
notify_view = View_New (client_reg, screen_view);
|
notify_view = View_New (client_reg, client_href, screen_view);
|
||||||
say_view = View_New (client_reg, screen_view);
|
say_view = View_New (client_reg, client_href, screen_view);
|
||||||
menu_view = View_New (client_reg, screen_view);
|
menu_view = View_New (client_reg, client_href, screen_view);
|
||||||
|
|
||||||
View_SetGravity (screen_view, grav_northwest);
|
View_SetGravity (screen_view, grav_northwest);
|
||||||
View_SetGravity (console_view, grav_northwest);
|
View_SetGravity (console_view, grav_northwest);
|
||||||
|
|
|
@ -616,7 +616,7 @@ create_window (view_t parent, int xpos, int ypos, int xlen, int ylen,
|
||||||
grav_t grav, void *obj, int opts, void (*draw) (view_t),
|
grav_t grav, void *obj, int opts, void (*draw) (view_t),
|
||||||
void (*setgeometry) (view_t))
|
void (*setgeometry) (view_t))
|
||||||
{
|
{
|
||||||
view_t view = View_New (server_reg, parent);
|
view_t view = View_New (server_reg, server_href, parent);
|
||||||
View_SetPos (view, xpos, ypos);
|
View_SetPos (view, xpos, ypos);
|
||||||
View_SetLen (view, xlen, ylen);
|
View_SetLen (view, xlen, ylen);
|
||||||
View_SetGravity (view, grav);
|
View_SetGravity (view, grav);
|
||||||
|
@ -679,11 +679,10 @@ init (void)
|
||||||
|
|
||||||
server_reg = ECS_NewRegistry ();
|
server_reg = ECS_NewRegistry ();
|
||||||
ECS_RegisterComponents (server_reg, server_components, server_comp_count);
|
ECS_RegisterComponents (server_reg, server_components, server_comp_count);
|
||||||
server_reg->href_comp = server_href;
|
|
||||||
|
|
||||||
get_size (&screen_x, &screen_y);
|
get_size (&screen_x, &screen_y);
|
||||||
|
|
||||||
sv_view = View_New (server_reg, nullview);
|
sv_view = View_New (server_reg, server_href, nullview);
|
||||||
View_SetPos (sv_view, 0, 0);
|
View_SetPos (sv_view, 0, 0);
|
||||||
View_SetLen (sv_view, screen_x, screen_y);
|
View_SetLen (sv_view, screen_x, screen_y);
|
||||||
View_SetGravity (sv_view, grav_northwest);
|
View_SetGravity (sv_view, grav_northwest);
|
||||||
|
|
|
@ -39,7 +39,6 @@ ECS_NewRegistry (void)
|
||||||
{
|
{
|
||||||
ecs_registry_t *reg = calloc (1, sizeof (ecs_registry_t));
|
ecs_registry_t *reg = calloc (1, sizeof (ecs_registry_t));
|
||||||
reg->next = Ent_Index (nullent);
|
reg->next = Ent_Index (nullent);
|
||||||
reg->href_comp = nullent;
|
|
||||||
return reg;
|
return reg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ hierarchy_UpdateTransformIndices (hierarchy_t *hierarchy, uint32_t start,
|
||||||
int offset)
|
int offset)
|
||||||
{
|
{
|
||||||
ecs_registry_t *reg = hierarchy->reg;
|
ecs_registry_t *reg = hierarchy->reg;
|
||||||
uint32_t href = reg->href_comp;
|
uint32_t href = hierarchy->href_comp;
|
||||||
for (size_t i = start; i < hierarchy->num_objects; i++) {
|
for (size_t i = start; i < hierarchy->num_objects; i++) {
|
||||||
if (ECS_EntValid (hierarchy->ent[i], reg)) {
|
if (ECS_EntValid (hierarchy->ent[i], reg)) {
|
||||||
hierref_t *ref = Ent_GetComponent (hierarchy->ent[i], href, reg);
|
hierref_t *ref = Ent_GetComponent (hierarchy->ent[i], href, reg);
|
||||||
|
@ -160,7 +160,7 @@ hierarchy_move (hierarchy_t *dst, const hierarchy_t *src,
|
||||||
uint32_t dstIndex, uint32_t srcIndex, uint32_t count)
|
uint32_t dstIndex, uint32_t srcIndex, uint32_t count)
|
||||||
{
|
{
|
||||||
ecs_registry_t *reg = dst->reg;
|
ecs_registry_t *reg = dst->reg;
|
||||||
uint32_t href = reg->href_comp;
|
uint32_t href = dst->href_comp;
|
||||||
Component_CopyElements (&ent_component,
|
Component_CopyElements (&ent_component,
|
||||||
dst->ent, dstIndex,
|
dst->ent, dstIndex,
|
||||||
src->ent, srcIndex, count);
|
src->ent, srcIndex, count);
|
||||||
|
@ -362,11 +362,12 @@ Hierarchy_RemoveHierarchy (hierarchy_t *hierarchy, uint32_t index,
|
||||||
}
|
}
|
||||||
|
|
||||||
hierarchy_t *
|
hierarchy_t *
|
||||||
Hierarchy_New (ecs_registry_t *reg, const hierarchy_type_t *type,
|
Hierarchy_New (ecs_registry_t *reg, uint32_t href_comp,
|
||||||
int createRoot)
|
const hierarchy_type_t *type, int createRoot)
|
||||||
{
|
{
|
||||||
hierarchy_t *hierarchy = PR_RESNEW (reg->hierarchies);
|
hierarchy_t *hierarchy = PR_RESNEW (reg->hierarchies);
|
||||||
hierarchy->reg = reg;
|
hierarchy->reg = reg;
|
||||||
|
hierarchy->href_comp = href_comp;
|
||||||
|
|
||||||
hierarchy->components = 0;
|
hierarchy->components = 0;
|
||||||
hierarchy->type = type;
|
hierarchy->type = type;
|
||||||
|
@ -402,17 +403,17 @@ Hierarchy_Delete (hierarchy_t *hierarchy)
|
||||||
}
|
}
|
||||||
|
|
||||||
hierarchy_t *
|
hierarchy_t *
|
||||||
Hierarchy_Copy (ecs_registry_t *dstReg, const hierarchy_t *src)
|
Hierarchy_Copy (ecs_registry_t *dstReg, uint32_t href_comp,
|
||||||
|
const hierarchy_t *src)
|
||||||
{
|
{
|
||||||
uint32_t href = dstReg->href_comp;
|
hierarchy_t *dst = Hierarchy_New (dstReg, href_comp, src->type, 0);
|
||||||
hierarchy_t *dst = Hierarchy_New (dstReg, src->type, 0);
|
|
||||||
size_t count = src->num_objects;
|
size_t count = src->num_objects;
|
||||||
|
|
||||||
Hierarchy_Reserve (dst, count);
|
Hierarchy_Reserve (dst, count);
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
for (size_t i = 0; i < count; i++) {
|
||||||
dst->ent[i] = ECS_NewEntity (dstReg);
|
dst->ent[i] = ECS_NewEntity (dstReg);
|
||||||
hierref_t *ref = Ent_AddComponent (dst->ent[i], href, dstReg);
|
hierref_t *ref = Ent_AddComponent (dst->ent[i], href_comp, dstReg);
|
||||||
ref->hierarchy = dst;
|
ref->hierarchy = dst;
|
||||||
ref->index = i;
|
ref->index = i;
|
||||||
}
|
}
|
||||||
|
@ -448,7 +449,7 @@ Hierarchy_SetParent (hierarchy_t *dst, uint32_t dstParent,
|
||||||
r.index = 0;
|
r.index = 0;
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
dst = Hierarchy_New (src->reg, src->type, 0);
|
dst = Hierarchy_New (src->reg, src->href_comp, src->type, 0);
|
||||||
}
|
}
|
||||||
r.hierarchy = dst;
|
r.hierarchy = dst;
|
||||||
r.index = hierarchy_insertHierarchy (dst, src, dstParent, &srcRoot);
|
r.index = hierarchy_insertHierarchy (dst, src, dstParent, &srcRoot);
|
||||||
|
|
|
@ -249,7 +249,7 @@ create_ent (uint32_t parent, const char *name)
|
||||||
ref->index = Hierarchy_InsertHierarchy (pref->hierarchy, 0,
|
ref->index = Hierarchy_InsertHierarchy (pref->hierarchy, 0,
|
||||||
pref->index, 0);
|
pref->index, 0);
|
||||||
} else {
|
} else {
|
||||||
ref->hierarchy = Hierarchy_New (test_reg, 0, 1);
|
ref->hierarchy = Hierarchy_New (test_reg, test_href, 0, 1);
|
||||||
ref->index = 0;
|
ref->index = 0;
|
||||||
}
|
}
|
||||||
ref->hierarchy->ent[ref->index] = ent;
|
ref->hierarchy->ent[ref->index] = ent;
|
||||||
|
@ -886,7 +886,6 @@ main (void)
|
||||||
{
|
{
|
||||||
test_reg = ECS_NewRegistry ();
|
test_reg = ECS_NewRegistry ();
|
||||||
ECS_RegisterComponents (test_reg, test_components, test_num_components);
|
ECS_RegisterComponents (test_reg, test_components, test_num_components);
|
||||||
test_reg->href_comp = test_href;
|
|
||||||
|
|
||||||
if (test_single_transform ()) { return 1; }
|
if (test_single_transform ()) { return 1; }
|
||||||
if (test_parent_child_init ()) { return 1; }
|
if (test_parent_child_init ()) { return 1; }
|
||||||
|
|
|
@ -225,7 +225,7 @@ bi (Font_Load)
|
||||||
bi (Passage_New)
|
bi (Passage_New)
|
||||||
{
|
{
|
||||||
gui_resources_t *res = _res;
|
gui_resources_t *res = _res;
|
||||||
passage_t *passage = Passage_New (text_reg);
|
passage_t *passage = Passage_New (text_reg, text_href);
|
||||||
R_INT (pr) = alloc_passage (res, passage);
|
R_INT (pr) = alloc_passage (res, passage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ bi (Text_Draw)
|
||||||
|
|
||||||
while (count-- > 0) {
|
while (count-- > 0) {
|
||||||
view_t psg_view = { .id = *ent++, .reg = text_reg,
|
view_t psg_view = { .id = *ent++, .reg = text_reg,
|
||||||
.comp = text_reg->href_comp};
|
.comp = text_href};
|
||||||
// first child is always a paragraph view, and all vies after the
|
// first child is always a paragraph view, and all vies after the
|
||||||
// first paragraph's first child are all text views
|
// first paragraph's first child are all text views
|
||||||
view_t para_view = View_GetChild (psg_view, 0);
|
view_t para_view = View_GetChild (psg_view, 0);
|
||||||
|
|
|
@ -213,7 +213,6 @@ Scene_NewScene (void)
|
||||||
|
|
||||||
scene->reg = ECS_NewRegistry ();
|
scene->reg = ECS_NewRegistry ();
|
||||||
ECS_RegisterComponents (scene->reg, scene_components, scene_num_components);
|
ECS_RegisterComponents (scene->reg, scene_components, scene_num_components);
|
||||||
scene->reg->href_comp = scene_href;
|
|
||||||
|
|
||||||
scene_resources_t *res = calloc (1, sizeof (scene_resources_t));
|
scene_resources_t *res = calloc (1, sizeof (scene_resources_t));
|
||||||
*(scene_resources_t **)&scene->resources = res;
|
*(scene_resources_t **)&scene->resources = res;
|
||||||
|
|
|
@ -215,7 +215,7 @@ Transform_New (ecs_registry_t *reg, transform_t parent)
|
||||||
ref->index = Hierarchy_InsertHierarchy (pref->hierarchy, 0,
|
ref->index = Hierarchy_InsertHierarchy (pref->hierarchy, 0,
|
||||||
pref->index, 0);
|
pref->index, 0);
|
||||||
} else {
|
} else {
|
||||||
ref->hierarchy = Hierarchy_New (reg, &transform_type, 1);
|
ref->hierarchy = Hierarchy_New (reg, scene_href, &transform_type, 1);
|
||||||
ref->index = 0;
|
ref->index = 0;
|
||||||
}
|
}
|
||||||
ref->hierarchy->ent[ref->index] = transform;
|
ref->hierarchy->ent[ref->index] = transform;
|
||||||
|
|
|
@ -88,7 +88,7 @@ add_entity (hierarchy_t *h, uint32_t parent)
|
||||||
{
|
{
|
||||||
uint32_t i = Hierarchy_InsertHierarchy (h, 0, parent, 0);
|
uint32_t i = Hierarchy_InsertHierarchy (h, 0, parent, 0);
|
||||||
h->ent[i] = ECS_NewEntity (h->reg);
|
h->ent[i] = ECS_NewEntity (h->reg);
|
||||||
hierref_t *ref = Ent_AddComponent (h->ent[i], h->reg->href_comp, h->reg);
|
hierref_t *ref = Ent_AddComponent (h->ent[i], h->href_comp, h->reg);
|
||||||
ref->hierarchy = h;
|
ref->hierarchy = h;
|
||||||
ref->index = i;
|
ref->index = i;
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,8 @@ Passage_ParseText (passage_t *passage, const char *text)
|
||||||
}
|
}
|
||||||
root_text.size = c - text;
|
root_text.size = c - text;
|
||||||
}
|
}
|
||||||
passage->hierarchy = Hierarchy_New (passage->reg, &passage_type, 0);
|
passage->hierarchy = Hierarchy_New (passage->reg, passage->href_comp,
|
||||||
|
&passage_type, 0);
|
||||||
Hierarchy_Reserve (passage->hierarchy,
|
Hierarchy_Reserve (passage->hierarchy,
|
||||||
1 + num_paragraphs + num_text_objects);
|
1 + num_paragraphs + num_text_objects);
|
||||||
#if 0
|
#if 0
|
||||||
|
@ -189,7 +190,7 @@ Passage_ParseText (passage_t *passage, const char *text)
|
||||||
for (uint32_t i = 0; i < h->num_objects; i++) {
|
for (uint32_t i = 0; i < h->num_objects; i++) {
|
||||||
psg_text_t *to = &passage_obj[i];
|
psg_text_t *to = &passage_obj[i];
|
||||||
uint32_t ent = h->ent[i];
|
uint32_t ent = h->ent[i];
|
||||||
hierref_t *ref = Ent_GetComponent (ent, reg->href_comp, reg);
|
hierref_t *ref = Ent_GetComponent (ent, h->href_comp, reg);
|
||||||
printf ("%3d %8x %3d %4d %4d '%.*s'\n", i, ent, ref->index,
|
printf ("%3d %8x %3d %4d %4d '%.*s'\n", i, ent, ref->index,
|
||||||
to->text, to->size, to->size, text + to->text);
|
to->text, to->size, to->size, text + to->text);
|
||||||
}
|
}
|
||||||
|
@ -197,11 +198,12 @@ Passage_ParseText (passage_t *passage, const char *text)
|
||||||
}
|
}
|
||||||
|
|
||||||
VISIBLE passage_t *
|
VISIBLE passage_t *
|
||||||
Passage_New (ecs_registry_t *reg)
|
Passage_New (ecs_registry_t *reg, uint32_t href_comp)
|
||||||
{
|
{
|
||||||
passage_t *passage = malloc (sizeof (passage_t));
|
passage_t *passage = malloc (sizeof (passage_t));
|
||||||
passage->text = 0;
|
passage->text = 0;
|
||||||
passage->reg = reg;
|
passage->reg = reg;
|
||||||
|
passage->href_comp = href_comp;
|
||||||
passage->hierarchy = 0;
|
passage->hierarchy = 0;
|
||||||
return passage;
|
return passage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -223,7 +223,7 @@ print_view (view_t view)
|
||||||
static int
|
static int
|
||||||
test_flow (testdata_t *child_views, int count, void (flow) (view_t, view_pos_t))
|
test_flow (testdata_t *child_views, int count, void (flow) (view_t, view_pos_t))
|
||||||
{
|
{
|
||||||
view_t flow_view = View_New (test_reg, nullview);
|
view_t flow_view = View_New (test_reg, test_href, nullview);
|
||||||
View_SetPos (flow_view, 0, 0);
|
View_SetPos (flow_view, 0, 0);
|
||||||
View_SetLen (flow_view, 256, 256);
|
View_SetLen (flow_view, 256, 256);
|
||||||
View_SetGravity (flow_view, grav_northwest);
|
View_SetGravity (flow_view, grav_northwest);
|
||||||
|
@ -232,7 +232,7 @@ test_flow (testdata_t *child_views, int count, void (flow) (view_t, view_pos_t))
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
testdata_t *td = &child_views[i];
|
testdata_t *td = &child_views[i];
|
||||||
view_t child = View_New (test_reg, flow_view);
|
view_t child = View_New (test_reg, test_href, flow_view);
|
||||||
View_SetPos (child, 0, 0);
|
View_SetPos (child, 0, 0);
|
||||||
View_SetLen (child, td->xlen, td->ylen);
|
View_SetLen (child, td->xlen, td->ylen);
|
||||||
View_SetGravity (child, grav_flow);
|
View_SetGravity (child, grav_flow);
|
||||||
|
@ -280,7 +280,6 @@ main (void)
|
||||||
|
|
||||||
test_reg = ECS_NewRegistry ();
|
test_reg = ECS_NewRegistry ();
|
||||||
ECS_RegisterComponents (test_reg, test_components, 1);
|
ECS_RegisterComponents (test_reg, test_components, 1);
|
||||||
test_reg->href_comp = test_href;
|
|
||||||
|
|
||||||
if (test_flow (right_down_views, right_down_count, view_flow_right_down)) {
|
if (test_flow (right_down_views, right_down_count, view_flow_right_down)) {
|
||||||
printf ("right-down failed\n");
|
printf ("right-down failed\n");
|
||||||
|
|
|
@ -224,7 +224,7 @@ static int
|
||||||
test_flow (testdata_t *child_views, int count,
|
test_flow (testdata_t *child_views, int count,
|
||||||
void (*flow) (view_t, view_pos_t))
|
void (*flow) (view_t, view_pos_t))
|
||||||
{
|
{
|
||||||
view_t flow_view = View_New (test_reg, nullview);
|
view_t flow_view = View_New (test_reg, test_href, nullview);
|
||||||
View_SetPos (flow_view, 0, 0);
|
View_SetPos (flow_view, 0, 0);
|
||||||
View_SetLen (flow_view, 256, 256);
|
View_SetLen (flow_view, 256, 256);
|
||||||
View_SetGravity (flow_view, grav_northwest);
|
View_SetGravity (flow_view, grav_northwest);
|
||||||
|
@ -232,7 +232,7 @@ test_flow (testdata_t *child_views, int count,
|
||||||
|
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
testdata_t *td = &child_views[i];
|
testdata_t *td = &child_views[i];
|
||||||
view_t child = View_New (test_reg, flow_view);
|
view_t child = View_New (test_reg, test_href, flow_view);
|
||||||
View_SetPos (child, 0, 0);
|
View_SetPos (child, 0, 0);
|
||||||
View_SetLen (child, td->xlen, td->ylen);
|
View_SetLen (child, td->xlen, td->ylen);
|
||||||
View_SetGravity (child, grav_flow);
|
View_SetGravity (child, grav_flow);
|
||||||
|
@ -280,7 +280,6 @@ main (void)
|
||||||
|
|
||||||
test_reg = ECS_NewRegistry ();
|
test_reg = ECS_NewRegistry ();
|
||||||
ECS_RegisterComponents (test_reg, test_components, 1);
|
ECS_RegisterComponents (test_reg, test_components, 1);
|
||||||
test_reg->href_comp = test_href;
|
|
||||||
|
|
||||||
if (test_flow (right_down_views, right_down_count, view_flow_right_down)) {
|
if (test_flow (right_down_views, right_down_count, view_flow_right_down)) {
|
||||||
printf ("right-down failed\n");
|
printf ("right-down failed\n");
|
||||||
|
|
|
@ -64,9 +64,8 @@ main (void)
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
ecs_registry_t *registry = ECS_NewRegistry ();
|
ecs_registry_t *registry = ECS_NewRegistry ();
|
||||||
ECS_RegisterComponents (registry, test_components, 1);
|
ECS_RegisterComponents (registry, test_components, 1);
|
||||||
registry->href_comp = test_href;
|
|
||||||
|
|
||||||
passage_t *passage = Passage_New (registry);
|
passage_t *passage = Passage_New (registry, test_href);
|
||||||
Passage_ParseText (passage, test_text);
|
Passage_ParseText (passage, test_text);
|
||||||
if (passage->hierarchy->childCount[0] != 3) {
|
if (passage->hierarchy->childCount[0] != 3) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
|
|
@ -92,7 +92,6 @@ Text_Init (void)
|
||||||
{
|
{
|
||||||
text_reg = ECS_NewRegistry ();
|
text_reg = ECS_NewRegistry ();
|
||||||
ECS_RegisterComponents (text_reg, text_components, text_type_count);
|
ECS_RegisterComponents (text_reg, text_components, text_type_count);
|
||||||
text_reg->href_comp = text_href;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct glyphnode_s {
|
typedef struct glyphnode_s {
|
||||||
|
@ -240,7 +239,7 @@ Text_View (font_t *font, passage_t *passage)
|
||||||
head = &(*head)->next;
|
head = &(*head)->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
view_t passage_view = View_New (text_reg, nullview);
|
view_t passage_view = View_New (text_reg, text_href, nullview);
|
||||||
glyphref_t passage_ref = {};
|
glyphref_t passage_ref = {};
|
||||||
glyphobj_t *glyphs = malloc (glyph_count * sizeof (glyphobj_t));
|
glyphobj_t *glyphs = malloc (glyph_count * sizeof (glyphobj_t));
|
||||||
glyphnode_t *g = glyph_nodes;
|
glyphnode_t *g = glyph_nodes;
|
||||||
|
@ -248,10 +247,10 @@ Text_View (font_t *font, passage_t *passage)
|
||||||
int psg_vertical = !!(psg_direction & 2);
|
int psg_vertical = !!(psg_direction & 2);
|
||||||
for (uint32_t i = 0; i < h->childCount[0]; i++) {
|
for (uint32_t i = 0; i < h->childCount[0]; i++) {
|
||||||
uint32_t paragraph = h->childIndex[0] + i;
|
uint32_t paragraph = h->childIndex[0] + i;
|
||||||
view_t paraview = View_New (text_reg, passage_view);
|
view_t paraview = View_New (text_reg, text_href, passage_view);
|
||||||
glyphref_t pararef = { .start = passage_ref.count };
|
glyphref_t pararef = { .start = passage_ref.count };
|
||||||
for (uint32_t j = 0; j < h->childCount[paragraph]; j++, g = g->next) {
|
for (uint32_t j = 0; j < h->childCount[paragraph]; j++, g = g->next) {
|
||||||
view_t textview = View_New (text_reg, paraview);
|
view_t textview = View_New (text_reg, text_href, paraview);
|
||||||
glyphref_t glyph_ref = {
|
glyphref_t glyph_ref = {
|
||||||
.start = passage_ref.count,
|
.start = passage_ref.count,
|
||||||
.count = g->count,
|
.count = g->count,
|
||||||
|
|
|
@ -136,10 +136,10 @@ static const hierarchy_type_t view_type = {
|
||||||
};
|
};
|
||||||
|
|
||||||
view_t
|
view_t
|
||||||
View_New (ecs_registry_t *reg, view_t parent)
|
View_New (ecs_registry_t *reg, uint32_t href_comp, view_t parent)
|
||||||
{
|
{
|
||||||
uint32_t view = ECS_NewEntity (reg);
|
uint32_t view = ECS_NewEntity (reg);
|
||||||
hierref_t *ref = Ent_AddComponent (view, reg->href_comp, reg);
|
hierref_t *ref = Ent_AddComponent (view, href_comp, reg);
|
||||||
|
|
||||||
if (parent.reg && parent.id != nullent) {
|
if (parent.reg && parent.id != nullent) {
|
||||||
hierref_t *pref = View_GetRef (parent);
|
hierref_t *pref = View_GetRef (parent);
|
||||||
|
@ -147,11 +147,11 @@ View_New (ecs_registry_t *reg, view_t parent)
|
||||||
ref->index = Hierarchy_InsertHierarchy (pref->hierarchy, 0,
|
ref->index = Hierarchy_InsertHierarchy (pref->hierarchy, 0,
|
||||||
pref->index, 0);
|
pref->index, 0);
|
||||||
} else {
|
} else {
|
||||||
ref->hierarchy = Hierarchy_New (reg, &view_type, 1);
|
ref->hierarchy = Hierarchy_New (reg, href_comp, &view_type, 1);
|
||||||
ref->index = 0;
|
ref->index = 0;
|
||||||
}
|
}
|
||||||
ref->hierarchy->ent[ref->index] = view;
|
ref->hierarchy->ent[ref->index] = view;
|
||||||
return (view_t) { .reg = reg, .id = view, .comp = reg->href_comp };
|
return (view_t) { .reg = reg, .id = view, .comp = href_comp };
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -88,14 +88,14 @@ qtv_sbar_init (void)
|
||||||
sv_view_t sv_view = *(sv_view_t *) comp;
|
sv_view_t sv_view = *(sv_view_t *) comp;
|
||||||
sv_view.setgeometry = 0;
|
sv_view.setgeometry = 0;
|
||||||
|
|
||||||
view = View_New (status.reg, status);
|
view = View_New (status.reg, status.comp, status);
|
||||||
View_SetPos (view, 0, 0);
|
View_SetPos (view, 0, 0);
|
||||||
View_SetLen (view, 8, 1);
|
View_SetLen (view, 8, 1);
|
||||||
View_SetGravity (view, grav_northwest);
|
View_SetGravity (view, grav_northwest);
|
||||||
sv_view.draw = draw_servers;
|
sv_view.draw = draw_servers;
|
||||||
Ent_SetComponent (view.id, server_view, view.reg, &sv_view);
|
Ent_SetComponent (view.id, server_view, view.reg, &sv_view);
|
||||||
|
|
||||||
view = View_New (status.reg, status);
|
view = View_New (status.reg, status.comp, status);
|
||||||
View_SetPos (view, 8, 0);
|
View_SetPos (view, 8, 0);
|
||||||
View_SetLen (view, 9, 1);
|
View_SetLen (view, 9, 1);
|
||||||
View_SetGravity (view, grav_northwest);
|
View_SetGravity (view, grav_northwest);
|
||||||
|
|
|
@ -156,7 +156,7 @@ CL_NetGraph (view_pos_t abs, view_pos_t len)
|
||||||
void
|
void
|
||||||
CL_NetGraph_Init (void)
|
CL_NetGraph_Init (void)
|
||||||
{
|
{
|
||||||
cl_netgraph_view = View_New (hud_registry, cl_screen_view);
|
cl_netgraph_view = View_New (hud_registry, hud_href, cl_screen_view);
|
||||||
View_SetPos (cl_netgraph_view, 0, 64);
|
View_SetPos (cl_netgraph_view, 0, 64);
|
||||||
View_SetLen (cl_netgraph_view, NET_TIMINGS + 16, cl_netgraph_height + 25);
|
View_SetLen (cl_netgraph_view, NET_TIMINGS + 16, cl_netgraph_height + 25);
|
||||||
View_SetGravity (cl_netgraph_view, grav_southwest);
|
View_SetGravity (cl_netgraph_view, grav_southwest);
|
||||||
|
|
|
@ -118,21 +118,21 @@ SV_Sbar_Init (void)
|
||||||
sv_view_t sv_view = *(sv_view_t *) comp;
|
sv_view_t sv_view = *(sv_view_t *) comp;
|
||||||
sv_view.setgeometry = 0;
|
sv_view.setgeometry = 0;
|
||||||
|
|
||||||
view = View_New (status.reg, status);
|
view = View_New (status.reg, status.comp, status);
|
||||||
View_SetPos (view, 0, 0);
|
View_SetPos (view, 0, 0);
|
||||||
View_SetLen (view, 11, 1);
|
View_SetLen (view, 11, 1);
|
||||||
View_SetGravity (view, grav_northwest);
|
View_SetGravity (view, grav_northwest);
|
||||||
sv_view.draw = draw_cpu;
|
sv_view.draw = draw_cpu;
|
||||||
Ent_SetComponent (view.id, server_view, view.reg, &sv_view);
|
Ent_SetComponent (view.id, server_view, view.reg, &sv_view);
|
||||||
|
|
||||||
view = View_New (status.reg, status);
|
view = View_New (status.reg, status.comp, status);
|
||||||
View_SetPos (view, 11, 0);
|
View_SetPos (view, 11, 0);
|
||||||
View_SetLen (view, 8, 1);
|
View_SetLen (view, 8, 1);
|
||||||
View_SetGravity (view, grav_northwest);
|
View_SetGravity (view, grav_northwest);
|
||||||
sv_view.draw = draw_rec;
|
sv_view.draw = draw_rec;
|
||||||
Ent_SetComponent (view.id, server_view, view.reg, &sv_view);
|
Ent_SetComponent (view.id, server_view, view.reg, &sv_view);
|
||||||
|
|
||||||
view = View_New (status.reg, status);
|
view = View_New (status.reg, status.comp, status);
|
||||||
View_SetPos (view, 19, 0);
|
View_SetPos (view, 19, 0);
|
||||||
View_SetLen (view, 18, 1);
|
View_SetLen (view, 18, 1);
|
||||||
View_SetGravity (view, grav_northwest);
|
View_SetGravity (view, grav_northwest);
|
||||||
|
|
Loading…
Reference in a new issue