Render Menu Code:
Code:
void cMenu::RenderMenu(void)
{
if(mSet.loaded == false)
{
this->InitiateMenu();
this->mSet.loaded = true;
}
//Show the menu if insert is pressed
if (GetAsyncKeyState(VK_INSERT)&1)
this->mSet.show = !this->mSet.show;
if(mSet.show)
{
//Menu controls
if(GetAsyncKeyState(VK_UP)&1)
this->mSet.current--;
if(GetAsyncKeyState(VK_DOWN)&1)
this->mSet.current++;
if(GetAsyncKeyState(VK_LEFT)&1)
if(this->mOpt[mSet.current].nopt > 0)
this->mOpt[mSet.current].nopt = this->mOpt[mSet.current].nopt - 1;
if(GetAsyncKeyState(VK_RIGHT)&1)
if(this->mOpt[mSet.current].nopt < this->mOpt[mSet.current].noptmax)
this->mOpt[mSet.current].nopt = this->mOpt[mSet.current].nopt + 1;
if(this->mSet.current < 1)
this->mSet.current = this->mSet.max-1;
if(this->mSet.current > this->mSet.max-1)
this->mSet.current = 1;
int headOffset = 0;
int textOffset = 0;
for(int i= this->mSet.min; i < this->mSet.max; i++)
{
//Render Menu Headers
for( int j = 0; j < this->mSet.NumOfHeaders; j++ )
{
if( i == this->mHead[j].Offset )
{
headOffset++;
Directx.DrawString(10, 32 + (headOffset*12) + (textOffset*11) + (11*i),0xFFAAAAAA, Directx.pFont, this->mHead[j].text);
textOffset++;
}
}
//Render the menu items
if(i == mSet.current)
{
Directx.DrawString(10, 32 + (headOffset*12) + (textOffset*11) + (11*i), 0xFFFF0000, Directx.pFont, this->mOpt[i].option);
}
if(i != mSet.current)
Directx.DrawString(10, 32 + (headOffset*12) + (textOffset*11) + (11*i),0xFFFFFFFF, Directx.pFont, this->mOpt[i].option);
if( this->mOpt[i].noptmax != 0 )
{
if( this->mOpt[i].option != "vJump" )
{
if( this->mOpt[i].nopt > 0 )
{
sprintf_s(this->mSet.optionstat, "On" );//%i .00
Directx.DrawString(95, 32 + (headOffset*12) + (textOffset*11) + (11*i), 0xFFFF0000, Directx.pFont, this->mSet.optionstat);
}
else
{
sprintf_s(this->mSet.optionstat, "Off" );//%i .00
Directx.DrawString(95, 32 + (headOffset*12) + (textOffset*11) + (11*i), 0xFF00FF00, Directx.pFont, this->mSet.optionstat);
}
}
else
{
if( this->mOpt[i].nopt <= 0 )
{
sprintf_s(this->mSet.optionstat, "Off" );//%i .00
Directx.DrawString(95, 32 + (headOffset*12) + (textOffset*11) + (11*i), 0xFF00FF00, Directx.pFont, this->mSet.optionstat);
}
else if( this->mOpt[i].nopt == 1 )
{
sprintf_s(this->mSet.optionstat, "Up" );//%i .00
Directx.DrawString(95, 32 + (headOffset*12) + (textOffset*11) + (11*i), 0xFFFF0000, Directx.pFont, this->mSet.optionstat);
}
else
{
sprintf_s(this->mSet.optionstat, "Down" );//%i .00
Directx.DrawString(95, 32 + (headOffset*12) + (textOffset*11) + (11*i), 0xFF7777FF, Directx.pFont, this->mSet.optionstat);
}
}
}
}
}