create lab directory in parent
abstract MazeParams to be able to set them easily doit.sh support new class creation updated README Signed-off-by: philippe lhardy <philippe@pavilionartlogiciel>
This commit is contained in:
@@ -82,6 +82,66 @@ public class Display extends JFrame
|
||||
maze.setWallSize(size);
|
||||
}
|
||||
|
||||
private static class MazeParamEditor
|
||||
implements MazeParams
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int maxdepth;
|
||||
File labdir;
|
||||
String name;
|
||||
|
||||
public MazeParamEditor()
|
||||
{
|
||||
name=null;
|
||||
labdir = new File("lab");
|
||||
}
|
||||
|
||||
public MazeParamEditor(File saveDir)
|
||||
{
|
||||
name=null;
|
||||
labdir = saveDir;
|
||||
}
|
||||
|
||||
public void consoleRead()
|
||||
{
|
||||
Scanner console = new Scanner(System.in);
|
||||
width = console.nextInt();
|
||||
height = console.nextInt();
|
||||
maxdepth = console.nextInt();
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public int getMaxDepth()
|
||||
{
|
||||
return maxdepth;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
name="lab" + width + "x" + height;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public File getSaveDir()
|
||||
{
|
||||
return labdir;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class MazeControler extends JPanel
|
||||
{
|
||||
public MazeControler()
|
||||
@@ -466,14 +526,12 @@ public class Display extends JFrame
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("enter width height and maxdepth");
|
||||
Scanner console = new Scanner(System.in);
|
||||
int width = console.nextInt();
|
||||
int height = console.nextInt();
|
||||
int maxdepth = console.nextInt();
|
||||
model = new LabyModel(width, height,maxdepth, new java.util.Random());
|
||||
int w = W / width;
|
||||
int h = H / height;
|
||||
System.out.println("enter width height and maxdepth");
|
||||
MazeParamEditor params = new MazeParamEditor();
|
||||
params.consoleRead();
|
||||
model = new LabyModel(params, new java.util.Random());
|
||||
int w = W / params.getWidth();
|
||||
int h = H / params.getHeight();
|
||||
if ( w < 5 ) w = 5;
|
||||
if ( h < 5 ) h = 5;
|
||||
MazeComponent comp = new MazeComponent(model,w,h,3,3);
|
||||
@@ -486,10 +544,9 @@ public class Display extends JFrame
|
||||
model.generateWithEntry(0, 0);
|
||||
LinkedList<Position> exits = new LinkedList<Position>();
|
||||
model.addEntryOrExit(-1,0);
|
||||
model.addEntryOrExit(width,height -1);
|
||||
model.addEntryOrExit(params.getWidth(),params.getHeight() -1);
|
||||
System.out.println("Generation completed");
|
||||
String name="lab" + width + "x" + height;
|
||||
File outfile = new File(new File("lab"), name + ".raw");
|
||||
File outfile = new File(params.getSaveDir(), params.getName() + ".raw");
|
||||
if ( ! outfile.exists())
|
||||
{
|
||||
System.out.println( "Saving to " + outfile + " ...");
|
||||
@@ -508,13 +565,13 @@ public class Display extends JFrame
|
||||
else {
|
||||
System.out.println( "" + outfile + " already exists");
|
||||
}
|
||||
outfile = new File(new File("lab"),name + ".stl");
|
||||
outfile = new File(params.getSaveDir(), params.getName() + ".stl");
|
||||
if ( ! outfile.exists())
|
||||
{
|
||||
System.out.println( "Saving to " + outfile + " ...");
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(outfile);
|
||||
Wall3d.streamWallsOut(name,(WallsProvider) model,out);
|
||||
Wall3d.streamWallsOut(params.getName(),(WallsProvider) model,out);
|
||||
out.flush();
|
||||
out.close();
|
||||
System.out.println( "... Done.");
|
||||
|
||||
Reference in New Issue
Block a user