I found a workaround, but that's another story.
Anyways, I got another problem and I don't feel like creating another thread for it, so...
int OptionsMenu(int x, int y, int w, int font, int num_options, int cancel)
//returns option # chosen. uses options[]. cancel toggles between if menu can be canceled out of
{
options_choice_hover = 0;
int height = FontHeight(font);
int temp = NewImage(w, height * num_options + (TXT_PADDING * 2));
DrawUIBox(0, 0, w, height * num_options + (TXT_PADDING * 2), temp);
int i;
for(i = 0; i < num_options; i++)
PrintString(ImageWidth(ui_cursor_img) + TXT_PADDING, height * i + TXT_PADDING,
temp, font, options[i]);
lastpressed = 0;
while(!b1) //while unconfirmed
{
Render();
Blit(x, y, temp, screen); //draw crap to the screen.
Blit(x, height * options_choice_hover + TXT_PADDING + y, ui_cursor_img, screen); //cursor
ShowPage();
//Check input
if(lastpressed == SCAN_UP)
{
// TODO: Play a little noise...
options_choice_hover = options_choice_hover - 1 % num_options;
lastpressed = 0;
}
if(lastpressed == SCAN_DOWN)
{
// TODO: Play a little noise...
options_choice_hover = options_choice_hover + 1 % num_options;
lastpressed = 0;
}
if(b2 && cancel) //cancel is nonzero, meaning menu can be canceled.
{
return MENU_CANCEL;
}
}
FreeImage(temp);
return options_choice_hover;
}
for some reason, a NullPointerException is thrown (and not caught) for the image "temp". As you can see, I'm pretty sure I initialized it. So uh, any ideas?