Sorry about that. Im planning to release all the source code, and even write up a detailed guide explaining how to add items and hacks to the menu , though by design the function are pretty self explanatory. Right now however the code is changing to fast to really keep anything anything, in detail, but the general design. Believe it or not that little bit took over 500 lines of code. It's a shame that the console doesn't really demonstrate it full potential, but it helps me with error checking early on. If I jumped straight to D3D I would not have thought of a lot of the techniques Im am using or planning to use.
Here I post a little of the code just to look at:
Code:
void Render(int x, int y, bool sel)
{
//x&y will not be used in console
/*NOTE: Most of this is to deal with the nullOption Don't really worry about.
I could have designed it differently, but there would be no need to add extra
stuff to this class of to the option structure for one exception.*/
int sizeOfOpt = (opt[0]->print()).size(); //trying to find out how much space the option needs
if(multiOpt)sizeOfOpt = 2;
string temp = settings->name;
int difference = settings->width - (settings->name.size() + 1 + sizeOfOpt);
if(difference >= 0)
{
SetColor((multiOpt && optSel == -1 && sel) || (!multiOpt && sel)); //opt[0] shares the line the the menu title o_O?! Or if multiOpt is on check to see if there's a negative index which again means item gets special color
cout<< settings->name << " " ;
for(; difference > 0; difference--){cout<< settings->pad;}//fill empty space with padding char
if(!multiOpt)cout<< opt[0]->print() << endl;// done! D:
else{
if(closed)cout<< ">>" << endl;// done! D:
else cout<< "->"<<endl;
}
}else{
int place = settings->name.size() + difference; //where to start deleting
temp.erase(place, (-1 * difference)); // delete characters from menuitem name to make it fit
if(!multiOpt)cout<< temp << " " << opt[0]->print() << endl;
else{
if(closed)cout<< temp << " " << ">>" << endl;
else cout<< temp << " " << "->" << endl;
}
}
//rendering rest of options. This will rarely occur since most MenuItems only have 1 option!
//But I added just in case someone wants the flexibility. ;)
if(!closed && multiOpt)
for(int i = 0; opt[i]; i++)
{
SetColor(sel && opt[i]->selected); //is this option selected?
cout<< opt[i]->print() <<endl;//don't worry about making sure it fits. =/
}
if(optSel > -1)opt[optSel]->selected = false;
selected = false;// is this item selected any longer?
return;
}
Code:
void Render()
{
itemArray[0]->Render(0,0,itemArray[0]->selected);
if(!closed)
for(int i = 1; i <= num_items; i++)
{
itemArray[i]->Render(0,0,itemArray[i]->selected);
}
selected = false;
return;
}
That's the render function of the Menu Item vs. the Categories render function. It shows that the brunt of the work is held in the MenuItems class, which why I will probably go back through and fix a lot of the code to make it run faster at the sake of the MenuItem looking messy. =/
EDIT: hmmm... idk if I even can change it... oh well, doesn't use too much memory I think.... since the other classes are so small, maybe its not so bad. =/