@Override public void buttonPressed(ClickableComponent button) { // save menu buttons if (saveMenuVisible) { if (button == confirmeSaveButton) { saveLevel(saveLevelName); updateLevels(); } if (button == confirmeSaveButton || button == cancelSaveButton) { saveMenuVisible = false; updateButtons = true; saveLevelName = ""; } return; } // tile buttons if (button instanceof LevelEditorButton) { LevelEditorButton lb = (LevelEditorButton) button; if (selectedButton != null && selectedButton != lb) { selectedButton.setActive(false); selectedButton = lb; } return; } // menu buttons if (!clicked) { if (button == newButton) { newLevel(); } else if (button == openButton) { selectedLevel = (selectedLevel < levels.size() - 1 ? selectedLevel + 1 : 0); openLevel(LevelList.getLevels().get(selectedLevel)); } else if (button == saveButton) { saveMenuVisible = true; updateButtons = true; } clicked = true; } else { clicked = false; } }
private void updateLevels() { LevelList.resetLevels(); levels = LevelList.getLevels(); }