typedef struct FdB_fbox_element
{
vec2 pos;
vec2 size;
vec4 draw_inf;
}FdB_fbox_element;
typedef struct FdB_fbox_node
{
struct FdB_fbox_node *next;
FdB_fbox_element *content;
}FdB_fbox_node;
typedef struct FdB_text_element
{
vec2 pos;
char *text;
}FdB_text_element;
typedef struct FdB_text_node
{
struct FdB_text_node *next;
FdB_text_element *content;
}FdB_text_node;
typedef struct FdB_box_element
{
vec2 pos;
vec2 size;
char *title;
int type;
int order;
FdB_fbox_node *Box_BG;
int BoxC_BG;
FdB_text_node *Box_Text;
int BoxC_Text;
FdB_fbox_node *Box_Content;
int BoxC_Content;
}FdB_box_element;
typedef struct FdB_box_node
{
struct FdB_box_node *next;
FdB_box_element *content;
}FdB_box_node;
typedef struct FdB_System
{
vec4 view_size;
FdB_box_node *Boxes;
int Boxes_c;
}FdB_System;
void FdB_NewFBox(unsigned int *size,FdB_fbox_node *first,vec4 posi,vec4 _draw_inf)
{
char tstr[256];
FdB_fbox_node *look=first;
FdB_fbox_node *newn=malloc(sizeof(FdB_fbox_node));
FdB_fbox_element *newe=malloc(sizeof(FdB_fbox_element));
newe->pos=c_vec2(posi.x,posi.y);
newe->size=c_vec2(posi.z,posi.w);
newe->draw_inf=_draw_inf;
newn->content=newe;
newn->next=NULL;
if(first==NULL)
{
first=newn;
}
else//we're somewhere in the list
{
while(look->next!=NULL)
{
look=look->next;//go to next one
}
look->next=newn;
}
(&size)++;
sprintf(tstr,"new FdB_fbox_node initialized. (0x%08x)",newn);
AddERR(tstr);
}
void FdB_DrawFBox(FdB_fbox_element *content)
{
DrawElement(content->draw_inf,c_vec4(content->pos.x,content->pos.y,content->size.x,content->size.y),false);
}
void FdB_DelFBox(int &size,FdB_fbox_node *first,unsigned int position)
{
unsigned int i;
FdB_fbox_node *look=first;
while(i<position)
{
look=look->next;
i++;
}
if(position==0 && look->next==NULL)
{
first=NULL;
free(look->content);
free(look);
}
else if(position==0)
{
first=look->next;
free(look->content);
free(look);
}
else if(look->next==NULL)
{
unsigned int j;
FdB_fbox_node *del=first;
while(j<position-1)
{
del=del->next;
j++;
}
del->next=look->next;
free(look->contnt);
free(look);
}
size--;
AddERR("FdB_fbox_node freed.");
}
void FdB_NewText(int &size,FdB_text_node *first,vec2 _pos,char *_text)
{
char tstr[256];
FdB_text_node *look=first;
FdB_text_node *newn=malloc(sizeof(FdB_text_node));
FdB_text_element*newe=malloc(sizeof(FdB_text_element));
newe->pos=_pos;
newe->text=_text;
newn->content=newe;
newn->next=NULL;
if(first==NULL)
{
first=newn;
}
else//we're somewhere in the list
{
while(look->next!=NULL)
{
look=look->next;//go to next one
}
look->next=newn;
}
size++;
sprintf(tstr,"new FdB_text_node initialized. (0x%08x)",newn);
AddERR(tstr);
}
void FdB_DelText(int &size,FdB_text_node *first,unsigned int position)
{
unsigned int i;
FdB_text_node *look=first;
while(i<position)
{
look=look->next;
i++;
}
if(position==0 && look->next==NULL)
{
first=NULL;
free(look->content);
free(look);
}
else if(position==0)
{
first=look->next;
free(look->content);
free(look);
}
else if(look->next==NULL)
{
unsigned int j;
FdB_text_node *del=first;
while(j<position-1)
{
del=del->next;
j++;
}
del->next=look->next;
free(look->content);
free(look);
}
size--;
AddERR("FdB_text_node freed");
}
void FdB_NewBox(int &size,FdB_box_node *first,char *title, vec4 posi, unsigned int type)
{
int i;
char tstr[256];
FdB_box_node *look=first;
FdB_box_node *newn=malloc(sizeof(FdB_box_node));
FdB_box_element *newe=malloc(sizeof(FdB_box_element));
newe->pos=c_vec2(posi.x,posi.y);
newe->size=c_vec2(posi.z,posi.w);
newe->type=type;
newe->title=title;
newe->order=0;
FdB_NewFBox(&newe->BoxC_BG,newe->Box_BG,c_vec4(posi.x,posi.y,16,16),be->Act_TL_Corner);
FdB_NewFBox(&newe->BoxC_BG,newe->Box_BG,c_vec4(posi.x+16,posi.y,posi.z-32,16),be->Act_T_Bar);
FdB_NewFBox(&newe->BoxC_BG,newe->Box_BG,c_vec4(posi.x+posi.z-32,posi.y,16,16),be->Act_TR_Corner);
newe->BoxC_BG=3;
newn->content=newe;
newn->next=NULL;
if(first==NULL)//no first means empty list
{
first=newn;
sprintf(tstr,"0x%08x",first);
AddERR(tstr);
}
else//we're somewhere in the list
{
while(look->next!=NULL)
{
look->content->order++;//Increase order of other windows so we can get this one as active
look=look->next;//go to next one
}
look->next=newn;
}
size++;
sprintf(tstr,"new FdB_box_node initialized. (0x%08x)", newn);
AddERR(tstr);
}
void FdB_DrawBox(FdB_fbox_node *first)
{
int i;
FdB_fbox_node *look=first;
while(look!=NULL)
{
FdB_DrawFBox(look->content);
look=look->next;
}
}
void FdB_DelBox(int &size,FdB_box_node *first,unsigned int position)
{
unsigned int i;
char tstr[256];
FdB_box_node *look=first;
while(i<position)
{
look=look->next;
i++;
}
for(i=look->content->BoxC_BG-1;i>=0;i--)
{
FdB_DelFBox(&look->content->BoxC_BG,look->content->Box_BG,i);
}
if(position==0 && look->next==NULL)
{
first=NULL;
free(look->content);
free(look);
}
else if(position==0)
{
first=look->next;
free(look->content);
free(look);
}
else if(look->next==NULL)
{
unsigned int j;
FdB_box_node *del=first;
while(j<position-1)
{
del=del->next;
j++;
}
del->next=look->next;
free(look->content);
free(look);
}
size--;
sprintf(tstr,"FdB_box_node freed. (%d)",size);
AddERR(tstr);
}
FdB_System* FdB_Init(vec4 Size)
{
char tstr[256];
FdB_System* fsys=malloc(sizeof(FdB_System));
fsys->view_size=Size;
fsys->Boxes_c=0;
fsys->Boxes=NULL;
sprintf(tstr,"FdB_System initialized. (0x%08x),view_size(%d,%d,%d,%d)",fsys,(int)fsys->view_size.x,(int)fsys->view_size.y,(int)fsys->view_size.z,(int)fsys->view_size.w);
AddERR(tstr);
return fsys;
}
FdB_System *Bsys;
void FdB_Free(FdB_System *fsys)
{
int i;
for(i=fsys->Boxes_c;i>=0;i--)
{
FdB_DelBox(&fsys->Boxes_c,fsys->Boxes,i);
AddERR("Hi.");
}
free(fsys);
AddERR("FdB_System freed.");
}
Users browsing this forum: No registered users and 1 guest