GameOption overhaul - moved more scattered bits into the enum.
- Added overridden methods read() and write() for reading from and writing to the options file within the GameOption enum, so that only 1 section needs to be changed when adding new options (instead of 3). - Added 'displayName' field to the GameOption enum, instead of repeating it in the parseOptions() and saveOptions() methods. - Added internal options (directories, port, theme song) into the GameOption enum for consistency. - Removed GameOption.NULL. Signed-off-by: Jeffrey Han <itdelatrisu@gmail.com>
This commit is contained in:
@@ -306,7 +306,7 @@ public class OptionsMenu extends BasicGameState {
|
||||
|
||||
// options (click only)
|
||||
GameOption option = getOptionAt(y);
|
||||
if (option != GameOption.NULL)
|
||||
if (option != null)
|
||||
option.click(container);
|
||||
|
||||
// special key entry states
|
||||
@@ -342,7 +342,7 @@ public class OptionsMenu extends BasicGameState {
|
||||
|
||||
// options (drag only)
|
||||
GameOption option = getOptionAt(oldy);
|
||||
if (option != GameOption.NULL)
|
||||
if (option != null)
|
||||
option.drag(container, diff);
|
||||
}
|
||||
|
||||
@@ -429,14 +429,13 @@ public class OptionsMenu extends BasicGameState {
|
||||
* @return the option, or GameOption.NULL if no such option exists
|
||||
*/
|
||||
private GameOption getOptionAt(int y) {
|
||||
GameOption option = GameOption.NULL;
|
||||
|
||||
if (y < textY || y > textY + (offsetY * maxOptionsScreen))
|
||||
return option;
|
||||
return null;
|
||||
|
||||
int index = (y - textY + Utils.FONT_LARGE.getLineHeight()) / offsetY;
|
||||
if (index < currentTab.options.length)
|
||||
option = currentTab.options[index];
|
||||
return option;
|
||||
if (index >= currentTab.options.length)
|
||||
return null;
|
||||
|
||||
return currentTab.options[index];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user