This is probably a silly question, but my brain is seriously not working here. I have custom save and load GUI's for my game, and they work perfectly, except for one bug.
If I make a call to the load game GUI, and there are no save games currently created, the game crashes. I know I can solve this with a simple 'if' statement, but I can't figure out how to phrase it.
Here is the code I use to call the GUI:
if (keycode == eKeyF7) //OPEN LOAD GAME GUI
lstLoadGames.SelectedIndex = 0;
lLoadName.Text = lstLoadGames.Items[lstLoadGames.SelectedIndex];
gLoadgame.Visible = true;
I know its crashing because the index is empty, but the only way I can think to fix it is by creating an auto-save when you start a new game, so you always have a save game. That is obviously a band-aid fix.
I did do a search to see if I could find the same problem, but I couldn't find one specific to my exact error, which is "ListBox.Items: invalid index specified"
Thanks in advance, and yes, I know once I see the code I will slap myself for not realized how easy the fix is lol.