NavigationBetweenViewController: rm setMenuView
This commit is contained in:
parent
99db8d4956
commit
aa32caaf42
@ -9,13 +9,12 @@ import fr.enssat.BoulderDash.helpers.LevelSaveHelper;
|
||||
import fr.enssat.BoulderDash.models.LevelModel;
|
||||
import fr.enssat.BoulderDash.views.HelpView;
|
||||
import fr.enssat.BoulderDash.views.LevelEditorView;
|
||||
import fr.enssat.BoulderDash.controllers.NavigationBetweenViewController;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* LevelEditorController
|
||||
*
|
||||
* <p>
|
||||
* Manages the level editor controller.
|
||||
*
|
||||
* @author Valerian Saliou <valerian@valeriansaliou.name>
|
||||
@ -50,10 +49,10 @@ public class LevelEditorController implements ActionListener {
|
||||
* @param event Action event
|
||||
*/
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
switch(event.getActionCommand()) {
|
||||
switch (event.getActionCommand()) {
|
||||
case "menu":
|
||||
this.levelEditorView.setVisible(false);
|
||||
this.nav.setMenuView();
|
||||
this.nav.getMenuView().setVisible(true);
|
||||
this.nav.getAudioLoadHelper().startMusic("game");
|
||||
|
||||
break;
|
||||
@ -67,7 +66,7 @@ public class LevelEditorController implements ActionListener {
|
||||
String levelId = this.levelEditorView.getSelectedLevel();
|
||||
LevelSaveHelper levelSave;
|
||||
|
||||
if(levelId == null || levelId.isEmpty()) {
|
||||
if (levelId == null || levelId.isEmpty()) {
|
||||
// Create a new level
|
||||
levelSave = new LevelSaveHelper(levelModel.getGroundLevelModel());
|
||||
} else {
|
||||
@ -79,7 +78,7 @@ public class LevelEditorController implements ActionListener {
|
||||
JOptionPane.showMessageDialog(frameDialog, "Level saved");
|
||||
|
||||
this.levelEditorView.openedLevelChange(levelSave.getLevelId());
|
||||
} catch(LevelConstraintNotRespectedException e) {
|
||||
} catch (LevelConstraintNotRespectedException e) {
|
||||
JFrame frameDialog = new JFrame("Error");
|
||||
JOptionPane.showMessageDialog(frameDialog, e.getMessage());
|
||||
}
|
||||
@ -90,7 +89,7 @@ public class LevelEditorController implements ActionListener {
|
||||
String levelId = this.levelEditorView.getSelectedLevel();
|
||||
JFrame frameDialog = new JFrame("Info");
|
||||
|
||||
if(levelId == null || levelId.isEmpty()) {
|
||||
if (levelId == null || levelId.isEmpty()) {
|
||||
JOptionPane.showMessageDialog(frameDialog, "Level not yet saved, no need to delete it!");
|
||||
} else {
|
||||
new LevelRemoveHelper(levelId);
|
||||
|
@ -6,14 +6,11 @@ import java.awt.event.ActionListener;
|
||||
import fr.enssat.BoulderDash.helpers.AudioLoadHelper;
|
||||
import fr.enssat.BoulderDash.models.LevelModel;
|
||||
import fr.enssat.BoulderDash.views.MenuView;
|
||||
import fr.enssat.BoulderDash.controllers.LevelEditorController;
|
||||
import fr.enssat.BoulderDash.controllers.GameController;
|
||||
|
||||
/**
|
||||
* Controller to navigate between the different views
|
||||
*
|
||||
* @author Colin Leverger <me@colinleverger.fr>
|
||||
*
|
||||
*/
|
||||
public class NavigationBetweenViewController implements ActionListener {
|
||||
private LevelEditorController levelEditorController;
|
||||
@ -100,15 +97,12 @@ public class NavigationBetweenViewController implements ActionListener {
|
||||
return this.menuView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the first view
|
||||
*
|
||||
* @param menuView
|
||||
*/
|
||||
public MenuView setMenuView() {
|
||||
this.menuView = new MenuView(this);
|
||||
return menuView;
|
||||
}
|
||||
// menuView has already been created in the constructor! No need to recreate it.
|
||||
//
|
||||
//public MenuView setMenuView() {
|
||||
// this.menuView = new MenuView(this);
|
||||
// return menuView;
|
||||
//}
|
||||
|
||||
/**
|
||||
* Get the pickedLevel
|
||||
|
Loading…
x
Reference in New Issue
Block a user