add reset button + title

default to 20x20 maze
This commit is contained in:
philippe lhardy
2017-12-02 17:56:27 +01:00
parent 378569bc8c
commit cddbd5f2d6
3 changed files with 40 additions and 5 deletions

View File

@@ -63,7 +63,7 @@ public class Display extends JFrame
Display(LabyModel model,int W, int H, MazeParams params) Display(LabyModel model,int W, int H, MazeParams params)
{ {
super("Maze display"); super(labels.getString("title"));
if (params != null) if (params != null)
{ {
// fixedParams = new MazeParamsFixed(params.getSaveDir(),params.getWidth(),params.getHeight(),params.getMaxDepth()); // fixedParams = new MazeParamsFixed(params.getSaveDir(),params.getWidth(),params.getHeight(),params.getMaxDepth());
@@ -114,6 +114,7 @@ public class Display extends JFrame
maze.resetWallsProvider(model); maze.resetWallsProvider(model);
model.setMazeListener(maze); model.setMazeListener(maze);
// we are in GUI event thread, need to release it and do it outside. // we are in GUI event thread, need to release it and do it outside.
new Thread() { new Thread() {
public void run() { public void run() {
@@ -122,6 +123,27 @@ public class Display extends JFrame
model.addEntryOrExit(params.getWidth(), params.getHeight() - 1); model.addEntryOrExit(params.getWidth(), params.getHeight() - 1);
} }
}.start(); }.start();
}
}
void resetModel()
{
// recreate labyrinth
if (params != null)
{
params = controler.getSettings().getParams();
model = new LabyModel(params, new java.util.Random());
maze.resetWallsProvider(model);
model.setMazeListener(maze);
// we are in GUI event thread, need to release it and do it outside.
new Thread() {
public void run() {
maze.changed(null,null,model);
}
}.start();
} }
} }
@@ -210,6 +232,17 @@ public class Display extends JFrame
} }
}); });
add(buttonCreate); add(buttonCreate);
JButton buttonReset = new JButton("reset");//labels.getString("reset"));
buttonReset.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
resetModel();
}
});
add(buttonReset);
} }
if ( params != null ) if ( params != null )
{ {
@@ -1044,7 +1077,7 @@ public class Display extends JFrame
} }
else else
{ {
MazeParamsFixed params = new MazeParamsFixed(new File("lab"),60,60,15); MazeParamsFixed params = new MazeParamsFixed(new File("lab"),20,20,12);
model = new LabyModel(params, new java.util.Random()); model = new LabyModel(params, new java.util.Random());
setupDisplay(model,W,H,params); setupDisplay(model,W,H,params);

View File

@@ -9,3 +9,4 @@ resolve = Resolve
create = Create create = Create
save = Save save = Save
quit = Quit quit = Quit
title = A Maz ing

View File

@@ -9,3 +9,4 @@ resolve = Résoudre
create = Créer create = Créer
save = Sauver save = Sauver
quit = Quitter quit = Quitter
title = La Bireinte