Ma wieder gelangweilt:
New ShowMenu function.
Code:
void D3DMenu::Show(CD3DFont *pFont,IDirect3DDevice9* pDevice)
{
int i,val,cy;
DWORD color;
if (!visible) return;
cy=y;
if (title) {
pFont->DrawText((float)(x+totwidth/2), (float)cy+1, col_title,title,D3DFONT_SHADOW|D3DFONT_CENTERED); //Drawing Title...You can modify it too
cy+=titleheight; }
for (i=0; i<noitems; i++) {
if (MENU[i]->typ==MENUTEXT) {
pFont->DrawText((float)x, (float)cy, col_text,MENU[i]->txt,D3DFONT_SHADOW); //If Text draw without Box
if (MENU[i]->opt) {
pFont->DrawText((float)(x+ofs), (float)cy, col_text,(char *)MENU[i]->opt, D3DFONT_RIGHT|D3DFONT_SHADOW); //Drawing Text
}
} else {//desc = MENU[cur]->description;
val=(MENU[i]->var)?(*MENU[i]->var):0;
// determine color
if (i==cur)
color=col_current; //Color = Current
else if (MENU[i]->typ==MENUGROUP)
color=col_group; //Color = Group Color
else if (MENU[i]->typ==MENUGROUP1)
color=(val)?col_on:col_off; //Color = col_on:col_off (Green:Red as Example)
else
color=(val)?col_on:col_off; //Color = col_on:col_off (Green:Red as Example)
DrawBorderedBox(x,cy,10,10,D3DCOLOR_ARGB(255, 000, 000, 000),color,pDevice); //Drawing our Box before Menu Items (In Black and in your choosen color)
pFont->DrawText((float)x+15, (float)cy, col_item,MENU[i]->txt,D3DFONT_SHADOW); //New Calculation,Drawing Menu Items
if (MENU[i]->opt) {
pFont->DrawText((float)(x+ofs), (float)cy, color,(char *)MENU[i]->opt[val],D3DFONT_RIGHT|D3DFONT_SHADOW); //Drawing on/off
}
}/*Original is made by Hans211,Modified by KingClem™*/
cy+=height;
}
}
New Drawbordered Function modified by KingClem™,Original from idk...
Code:
HRESULT D3DMenu::DrawBorderedBox(int x, int y, int h, int w,DWORD color1, DWORD color2, LPDIRECT3DDEVICE9 pDevice)
{
struct croner { D3DXVECTOR4 p; DWORD c; } cr[5];
// coord -0.5f prevents point filtering distorsions at the edges (smudging)
cr[0].p = D3DXVECTOR4(x+0-0.5f,y+h-0.5f,0.0f,1.0f); cr[0].c = color1;
cr[1].p = D3DXVECTOR4(x+0-0.5f,y+0-0.5f,0.0f,1.0f); cr[1].c = color1;
cr[2].p = D3DXVECTOR4(x+w-0.5f,y+h-0.5f,0.0f,1.0f); cr[2].c = color1;
cr[3].p = D3DXVECTOR4(x+w-0.5f,y+0-0.5f,0.0f,1.0f); cr[3].c = color1;
pDevice->SetTexture(0, NULL);
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP, 2, cr, sizeof(croner));
// coord -0.5f prevents point filtering distorsions at the edges (smudging)
cr[0].p = D3DXVECTOR4(x+0-0.5f,y+h-0.5f,0.0f,3.0f); cr[0].c = color2;
cr[1].p = D3DXVECTOR4(x+0-0.5f,y+0-0.5f,0.0f,3.0f); cr[1].c = color2;
cr[2].p = D3DXVECTOR4(x+w-0.5f,y+0-0.5f,0.0f,3.0f); cr[2].c = color2;
cr[3].p = D3DXVECTOR4(x+w-0.5f,y+h-0.5f,0.0f,3.0f); cr[3].c = color2;
cr[4].p = D3DXVECTOR4(x+0-0.5f,y+h-0.5f,0.0f,3.0f); cr[4].c = color2;
pDevice->SetTexture(0, NULL);
pDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
pDevice->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE);
pDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 3, cr, sizeof(croner));
return S_OK;
}
It can look like this:
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]