void tintArea(int x,int y,int w,int h, ColorEntry* clr)
{
oEngfuncs.pfnFillRGBA(x,y,w,h,clr->r,clr->g,clr->b,clr->a);
}
void tintAreaH(int x,int y,int w,int h, ColorEntry* clr1,ColorEntry* clr2)
{
for(int v=y;v<=(y+h-1);v+=2)
{
oEngfuncs.pfnFillRGBA(x, v, w, 1,clr1->r,clr1->g,clr1->b,clr1->a);
oEngfuncs.pfnFillRGBA(x,v+1, w, 1,clr2->r,clr2->g,clr2->b,clr2->a);
}
}
void tintAreaV(int x,int y,int w,int h, ColorEntry* clr1,ColorEntry* clr2)
{
for(int v=x;v<=(x+w-1);v+=2)
{
oEngfuncs.pfnFillRGBA( v, y, 1, h,clr1->r,clr1->g,clr1->b,clr1->a);
oEngfuncs.pfnFillRGBA(v+1, y, 1, h,clr2->r,clr2->g,clr2->b,clr2->a);
}
}
void Border(int x,int y,int w,int h,int th,ColorEntry* clr)
{
oEngfuncs.pfnFillRGBA( x, y, w, th,clr->r,clr->g,clr->b,clr->a);// Top
oEngfuncs.pfnFillRGBA( x,y+h,w+th, th,clr->r,clr->g,clr->b,clr->a);// Bottom
oEngfuncs.pfnFillRGBA( x, y, th, h,clr->r,clr->g,clr->b,clr->a);// Left
oEngfuncs.pfnFillRGBA(x+w, y, th,h+th,clr->r,clr->g,clr->b,clr->a);// Right
}
void DrawGrid(int x,int y,int w,int h,int size,ColorEntry* clr1,ColorEntry* clr2)
{
int s = size;
int s1 = s + 1;
int s2 = s - 1;
for(int v=x;v<=(x+w-s2);v+=s1)
{
oEngfuncs.pfnFillRGBA( v, y, s, h,clr1->r,clr1->g,clr1->b,clr1->a);
oEngfuncs.pfnFillRGBA(v+s, y, s, h,clr2->r,clr2->g,clr1->b,clr2->a);
}
for(v=y;v<=(y+h-s2);v+=s1)
{
oEngfuncs.pfnFillRGBA(x, v, w, s,clr1->r,clr1->g,clr1->b,clr1->a);
oEngfuncs.pfnFillRGBA(x,v+s, w, s,clr2->r,clr2->g,clr2->b,clr2->a);
}
}
void tintArea(int x,int y,int w,int h,int type, ColorEntry* clr1,ColorEntry* clr2)
{
switch(type)
{
case 0://normal
{tintArea(x,y,w,h,clr1); }
break;
case 1://V Grid
{tintAreaV(x,y,w,h,clr1,clr2); }
break;
case 2://H Grid
{tintAreaH(x,y,w,h,clr1,clr2); }
break;
case 3://Grid
{DrawGrid(x,y,w,h,5,clr1,clr2); }
break;
case 4://Normal/Border
{tintArea(x,y,w,h,clr1);Border(x,y,w,h,1,colorList.get(45)); }
break;
case 5://V Grid/Border
{tintAreaV(x,y,w,h,clr1,clr2);Border(x,y,w,h,1,colorList.get(45)); }
break;
case 6://H Grid/Border
{tintAreaH(x,y,w,h,clr1,clr2);Border(x,y,w,h,1,colorList.get(45)); }
break;
case 7://Grid/Border
{DrawGrid(x,y,w,h,5,clr1,clr2);Border(x,y,w,h,1,colorList.get(45)); }
break;
case 8://Line
{oEngfuncs.pfnFillRGBA(x, y, w, h,clr1->r,clr1->g,clr1->b,clr1->a); }
}
}
//=======================================================================
void RetarTMenu::GlowStr(int x,int y,ColorEntry* clr1,ColorEntry* clr2,const char *fmt, ... )
{
va_list va_alist;
char buf[256];
va_start (va_alist, fmt);
_vsnprintf (buf, sizeof(buf), fmt, va_alist);
va_end (va_alist);
DrawHudString(x-2, y,clr1->r,clr1->g,clr1->b,buf); // Left
DrawHudString(x+2, y,clr1->r,clr1->g,clr1->b,buf); // Right
DrawHudString( x,y+2,clr1->r,clr1->g,clr1->b,buf); // Top
DrawHudString( x,y-2,clr1->r,clr1->g,clr1->b,buf); // Bottom
DrawHudString(x-1,y-1,clr1->r,clr1->g,clr1->b,buf); // Left
DrawHudString(x+1,y+1,clr1->r,clr1->g,clr1->b,buf); // Right
DrawHudString(x-1,y+1,clr1->r,clr1->g,clr1->b,buf); // Top
DrawHudString(x+1,y-1,clr1->r,clr1->g,clr1->b,buf); // Bottom
DrawHudString(x,y,clr2->r,clr2->g,clr2->b,buf);
}
void RetarTMenu::MenuStr(int x,int y,const char *fmt, ... )
{
va_list va_alist;
char buf[256];
va_start (va_alist, fmt);
_vsnprintf(buf, sizeof(buf), fmt, va_alist);
va_end (va_alist);
int w = cvar.menu_w;
switch(cvar.menu_type)
{
case 1://V Grids/Glow Text/Border
{
GlowStr (x+10,y,colorList.get(39),colorList.get(45),buf);
tintArea(x,y - 3,w,20,4,colorList.get(22),colorList.get(22));
}
break;
case 2://Glow Text/Border
{
GlowStr (x+10,y,colorList.get(39),colorList.get(45),buf);
tintArea(x,y - 6,w,25,4,colorList.get(22),colorList.get(22));
}
break;
case 3://Normal
{
DrawHudString (x+10,y,255,255,255,buf);
tintArea (x,y - 3,w,20,0,colorList.get(22),colorList.get(22));
}
break;
case 4://TODO: make something here
{
}
break;
}
}
void RetarTMenu::MenuSelStr(int x,int y,const char *fmt, ... )
{
va_list va_alist;
char buf[256];
va_start (va_alist, fmt);
_vsnprintf(buf, sizeof(buf), fmt, va_alist);
va_end (va_alist);
int w = cvar.menu_w;
switch(cvar.menu_type)
{
case 1://V Grids/Glow Text/Border
{
GlowStr (x+10,y,colorList.get(38),colorList.get(45),buf);
tintArea(x,y - 3,w,20,4,colorList.get(21),colorList.get(22));
}
break;
case 2://Glow Text/Border
{
GlowStr (x+10,y,colorList.get(38),colorList.get(45),buf);
tintArea(x,y - 6,w,25,4,colorList.get(21),colorList.get(22));
}
break;
case 3://Normal
{
DrawHudString (x+10,y,255,255,255,buf);
tintArea (x,y - 3,w,20,0,colorList.get(21),colorList.get(22));
}
break;
case 4://TODO: make something here
{
}
break;
}
}
//========================================================================================
// txtglow[38] seltxtglow[48]
void RetarTMenu::Draw()
{
vector<OgcCommandMenu::MenuEntry>& items = curMenu->items;
if(!menu_active) return;
if(!curMenu) { curMenu = ogcMenu.baseMenu; }
int x = cvar.menu_x;
int y = cvar.menu_y;
int w = cvar.menu_w;
static OgcCommandMenu::MenuEntry& item = items[0];
int i;
switch(cvar.menu_type)
{
case 1:
{
for(int i=0;i<items.size();i++)
{
item = items;
MenuStr(x,y-30,const_cast<char*>(curMenu->name.c_str()));
if(i == curMenu->selection) { MenuSelStr(x,y+(26*i),const_cast<char*>(item.name.c_str())); }
else { MenuStr (x,y+(26*i),const_cast<char*>(item.name.c_str())); }
item = items[0];
}
}
break;
case 2:
{
for(int i=0;i<items.size();i++)
{
static OgcCommandMenu::MenuEntry& item = items;
int x2 = x+w+25;
static int s=0;
static int p1=0,n2=0,f1=0,f2=0;
static int n1=0,p2=0,l1=0,l2=0;
MenuStr(x,y,const_cast<char*>(curMenu->name.c_str()));
if(i == curMenu->selection)
{
s = curMenu->selection;
p1 = s - 1;
n1 = s + 1;
f1 = s - items.size() - 1;
l1 = s + items.size() - 1;
/////////////////////////
p2 = s - 2;
n2 = s + 2;
f2 = s - items.size() - 2;
l2 = s + items.size() - 2;
MenuSelStr(x2,y,const_cast<char*>(items[s].name.c_str()));
}
else
{
if(s==items.size()-2 || s<items.size()-2)
MenuStr(x2,y+(28*2),const_cast<char*>(items[f2].name.c_str()));
else
MenuStr(x2,y+(28*2),const_cast<char*>(items[n1].name.c_str()));
if(s==items.size()-1)
MenuStr(x2,y+(28*1),const_cast<char*>(items[f1].name.c_str()));
else
MenuStr(x2,y+(28*1),const_cast<char*>(items[n1].name.c_str()));
///////////////////////////////////////////////////////////////////
if(s==0 || s>1)
MenuStr(x2,y-(28*2),const_cast<char*>(items[l2].name.c_str()));
else
MenuStr(x2,y-(28*2),const_cast<char*>(items[p1].name.c_str()));
if(s==0)
MenuStr(x2,y-(28*1),const_cast<char*>(items[l1].name.c_str()));
else
MenuStr(x2,y-(28*1),const_cast<char*>(items[p1].name.c_str()));
}
}
}
break;
case 3:
{
for(int i=0;i<items.size();i++)
{
static OgcCommandMenu::MenuEntry& item = items;
MenuStr(x,y-22,const_cast<char*>(curMenu->name.c_str()));
if(curMenu->selection == i) { MenuSelStr(x,y+(22*i)-1,const_cast<char*>(item.name.c_str())); }
else { MenuStr(x,y+(22*i),const_cast<char*>(item.name.c_str())); }
}
}
break;
case 4://TODO: make something here
{
info.menu = true;
for(int i=0;i<items.size();i++)
{
static OgcCommandMenu::MenuEntry& item = items;
MenuStr(x,y-22,const_cast<char*>(curMenu->name.c_str()));
if(info.mousepos[1] < x &&
info.mousepos[1] > w &&
info.mousepos[2] < y+(22*i) &&
info.mousepos[2] > y+(22*i)+25)
{
curMenu->selection = i;
MenuSelStr(x,y+(22*i)-1,const_cast<char*>(item.name.c_str()));
}
else
{
MenuStr(x,y+(22*i),const_cast<char*>(item.name.c_str()));
}
}
}
break;
}
}