OoliteProject / oolite

The main Oolite repository.
https://www.oolite.space
543 stars 70 forks source link

Fixes issue with too many choices to fit on mission screen #477

Closed phkb closed 3 months ago

phkb commented 3 months ago

This PR fixes the issue where too many choices have been defined in the options dictionary to fit on the current mission screen.

Essentially, what I'm doing here is (apart from putting a notice in the log) ignoring choices that fall outside the scope of the screen. This could potentially leave the screen in a weird state, if (say) the option to close the screen is one of the excluded options.

As an alternative, I could ignore all options if too many have been defined. Let me know your preference.

AnotherCommander commented 3 months ago

I think it looks like a reasonable fix. The root cause of the reported thrown exception is almost certainly the NSMakeRange at line 2093 and to stop the exception one must ensure that the parameters to that method are positive integers - which you do with this fix. I feel a bit uncertain about the best way to handle the problem of overflowing options, but if we go with ignore all options, then it would probably be best to write something on the screen along the lines of [options overflow, all ignored] or something like that. This of course has the problem of immediately breaking immersion, since it takes the user out of the game environment by looking like a debug screen. I'll leave the hard choice to you ;-), but I wouldn't object if this PR gets merged the way it is.