add reset button + title
default to 20x20 maze
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -9,3 +9,4 @@ resolve = Resolve
|
|||||||
create = Create
|
create = Create
|
||||||
save = Save
|
save = Save
|
||||||
quit = Quit
|
quit = Quit
|
||||||
|
title = A Maz ing
|
||||||
@@ -9,3 +9,4 @@ resolve = Résoudre
|
|||||||
create = Créer
|
create = Créer
|
||||||
save = Sauver
|
save = Sauver
|
||||||
quit = Quitter
|
quit = Quitter
|
||||||
|
title = La Bireinte
|
||||||
Reference in New Issue
Block a user