export many layers
- remark : wrong merge code ( dverged on two latptops .. ) possible loss
This commit is contained in:
@@ -13,6 +13,16 @@ extends Range
|
|||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** sub layers **/
|
||||||
|
public LabyLayers(LabyLayers pLayers, Range pRange)
|
||||||
|
{
|
||||||
|
for ( int layer = pRange.getMin(); layer <= pRange.getMax(); layer ++)
|
||||||
|
{
|
||||||
|
addLabyModel(layer, pLayers.getLayer(layer));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addLabyModel(int z, LabyModel model)
|
public void addLabyModel(int z, LabyModel model)
|
||||||
{
|
{
|
||||||
updateBounds(z);
|
updateBounds(z);
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ implements StatusListener
|
|||||||
Container con = this.getContentPane();
|
Container con = this.getContentPane();
|
||||||
JScrollPane scrollableMaze = new JScrollPane(maze);
|
JScrollPane scrollableMaze = new JScrollPane(maze);
|
||||||
con.add(scrollableMaze, BorderLayout.CENTER);
|
con.add(scrollableMaze, BorderLayout.CENTER);
|
||||||
controler = new MazeControler(params);
|
controler = new MazeControler(this,params);
|
||||||
con.add(controler.getMoveControl(), BorderLayout.NORTH);
|
con.add(controler.getMoveControl(), BorderLayout.NORTH);
|
||||||
con.add(controler.getGenerationControl(), BorderLayout.SOUTH);
|
con.add(controler.getGenerationControl(), BorderLayout.SOUTH);
|
||||||
|
|
||||||
@@ -294,430 +294,7 @@ implements StatusListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private class MazeControler extends JPanel {
|
void loadRaw() {
|
||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private MazeSettings settings = null;
|
|
||||||
|
|
||||||
private void setMazeName(String pName) {
|
|
||||||
MazeParamsFixed p = (MazeParamsFixed) params;
|
|
||||||
p.setName(pName);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JMenu createLoadingMenu() {
|
|
||||||
JMenu loadMenu = new JMenu(MazeDefault.labels.getString("load") );
|
|
||||||
|
|
||||||
final JTextField loadName = new JTextField("newlaby");
|
|
||||||
|
|
||||||
loadMenu.add(loadName);
|
|
||||||
|
|
||||||
Action loadRawAction = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("load raw");
|
|
||||||
|
|
||||||
String filename = loadName.getText();
|
|
||||||
|
|
||||||
if ((filename.length() > 0)) {
|
|
||||||
setMazeName(filename);
|
|
||||||
loadRaw();
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
JButton loadRawButton = new JButton(MazeDefault.labels.getString("load" ) + " raw");
|
|
||||||
loadRawButton.addActionListener(loadRawAction);
|
|
||||||
loadMenu.add(loadRawButton);
|
|
||||||
|
|
||||||
Action loadImcAction = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("load Imc");
|
|
||||||
|
|
||||||
String filename = loadName.getText();
|
|
||||||
|
|
||||||
if ((filename.length() > 0)) {
|
|
||||||
setMazeName(filename);
|
|
||||||
loadImc(false);
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
JButton loadImcButton = new JButton(MazeDefault.labels.getString("load" ) + " imc");
|
|
||||||
loadImcButton.addActionListener(loadImcAction);
|
|
||||||
|
|
||||||
loadMenu.add(loadImcButton);
|
|
||||||
|
|
||||||
Action loadDrawingAction = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("load Drawing");
|
|
||||||
|
|
||||||
String filename = loadName.getText();
|
|
||||||
|
|
||||||
if ((filename.length() > 0)) {
|
|
||||||
setMazeName(filename);
|
|
||||||
loadDrawing(false);
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
JButton loadDrawingButton = new JButton(MazeDefault.labels.getString("load" ) + " Drawing");
|
|
||||||
loadDrawingButton.addActionListener(loadDrawingAction);
|
|
||||||
|
|
||||||
loadMenu.add(loadDrawingButton);
|
|
||||||
|
|
||||||
Action loadOsmAction = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("load Osm");
|
|
||||||
|
|
||||||
String filename = loadName.getText();
|
|
||||||
|
|
||||||
if ((filename.length() > 0)) {
|
|
||||||
setMazeName(filename);
|
|
||||||
// UTM 32T ? approx (long,lat) to meter
|
|
||||||
loadOsm(false, 78000,78000);
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
loadMenu.add(newLoadButton("osm", loadOsmAction));
|
|
||||||
|
|
||||||
loadMenu.add(newLoadButton("we",
|
|
||||||
new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("load WoldEdit");
|
|
||||||
|
|
||||||
String filename = loadName.getText();
|
|
||||||
|
|
||||||
if ((filename.length() > 0)) {
|
|
||||||
setMazeName(filename);
|
|
||||||
loadWorldEdit(false);
|
|
||||||
refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
));
|
|
||||||
return loadMenu;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JMenu createSavingMenu() {
|
|
||||||
final JTextField saveName = new JTextField("newlaby");
|
|
||||||
|
|
||||||
final JButton savePngButton = newSaveButton( "png",
|
|
||||||
new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("save png");
|
|
||||||
setMazeName(saveName.getText());
|
|
||||||
savePng();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final JButton saveSvgButton = newSaveButton("svg",
|
|
||||||
new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
writeSentence("save svg");
|
|
||||||
setMazeName(saveName.getText());
|
|
||||||
saveSvg();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final JButton saveButton = newSaveButton("raw",
|
|
||||||
new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
setMazeName(saveName.getText());
|
|
||||||
MazeParamsFixed p = (MazeParamsFixed) params;
|
|
||||||
save(p, model);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
Action saveImcAction = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
setMazeName(saveName.getText());
|
|
||||||
saveImc();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
final JButton saveImcButton = newSaveButton("imc", saveImcAction);
|
|
||||||
|
|
||||||
Action saveStlAction = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
setMazeName(saveName.getText());
|
|
||||||
MazeParamsFixed p = (MazeParamsFixed) params;
|
|
||||||
saveStl(p, model,stlsettings.createParams());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
final JButton saveStlButton = newSaveButton("stl", saveStlAction);
|
|
||||||
|
|
||||||
Action saveTextAction = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
setMazeName(saveName.getText());
|
|
||||||
saveText();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
final JButton saveTextButton = newSaveButton("txt", saveTextAction);
|
|
||||||
|
|
||||||
final JButton saveWorleEditButton = newSaveButton( "we",
|
|
||||||
new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
setMazeName(saveName.getText());
|
|
||||||
saveWorldEdit();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
stlsettings = new Maze3dSettings(new Maze3dParams());
|
|
||||||
|
|
||||||
JMenu saveMenu = new JMenu(MazeDefault.labels.getString("save") );
|
|
||||||
saveMenu.add(saveName);
|
|
||||||
saveMenu.add(saveSvgButton);
|
|
||||||
saveMenu.add(savePngButton);
|
|
||||||
saveMenu.add(saveButton);
|
|
||||||
saveMenu.add(stlsettings);
|
|
||||||
saveMenu.add(saveStlButton);
|
|
||||||
saveMenu.add(saveImcButton);
|
|
||||||
saveMenu.add(saveTextButton);
|
|
||||||
saveMenu.add(saveWorleEditButton);
|
|
||||||
|
|
||||||
return saveMenu;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private JButton newActionButton(String actionName, String format, Action action) {
|
|
||||||
final JButton saveTextButton = new JButton(MazeDefault.labels.getString(actionName) + " " + format);
|
|
||||||
saveTextButton.addActionListener(action);
|
|
||||||
return saveTextButton;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JButton newSaveButton(String format, Action action) {
|
|
||||||
return newActionButton("save",format,action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JButton newLoadButton(String format, Action action) {
|
|
||||||
return newActionButton("load",format,action);
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel createResolveQuitBar() {
|
|
||||||
JPanel resolveQuitBar = new JPanel(new FlowLayout());
|
|
||||||
|
|
||||||
JButton buttonCreate = new JButton(MazeDefault.labels.getString("create"));
|
|
||||||
buttonCreate.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
recreateModel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
resolveQuitBar.add(buttonCreate);
|
|
||||||
|
|
||||||
JButton resolveButton = new JButton(MazeDefault.labels.getString("resolve"));
|
|
||||||
resolveButton.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("Resolving");
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
resolveQuitBar.add(resolveButton);
|
|
||||||
|
|
||||||
JButton reverseButton = new JButton(MazeDefault.labels.getString("reverse"));
|
|
||||||
reverseButton.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("Reversing");
|
|
||||||
mGrow ^= reverse(mGrow);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
resolveQuitBar.add(reverseButton);
|
|
||||||
|
|
||||||
|
|
||||||
final JButton quitButton = new JButton(MazeDefault.labels.getString("quit"));
|
|
||||||
Action quitAction = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("quit");
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
quitButton.addActionListener(quitAction);
|
|
||||||
|
|
||||||
resolveQuitBar.add(quitButton);
|
|
||||||
|
|
||||||
JButton buttonReset = new JButton("reset");//MazeDefault.labels.getString("reset"));
|
|
||||||
buttonReset.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
resetModel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
resolveQuitBar.add(buttonReset);
|
|
||||||
|
|
||||||
return resolveQuitBar;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public MazeControler(MazeParams params) {
|
|
||||||
// super(new BorderLayout());
|
|
||||||
super();
|
|
||||||
BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS);
|
|
||||||
setLayout(layout);
|
|
||||||
|
|
||||||
JMenuBar menuBar = new JMenuBar();
|
|
||||||
menuBar.add(createSavingMenu());
|
|
||||||
menuBar.add(createLoadingMenu());
|
|
||||||
add(menuBar);
|
|
||||||
|
|
||||||
add(createResolveQuitBar());
|
|
||||||
|
|
||||||
JPanel controlMovesPanel = new JPanel(new BorderLayout());
|
|
||||||
settings = new MazeSettings(params);
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
Action goNorth = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("go North");
|
|
||||||
goNorth();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
JButton north = addDirection(this, MazeDefault.labels.getString("north"), "UP", goNorth);
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
Action goEast = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("go East");
|
|
||||||
goEast();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
JButton east = addDirection(this, MazeDefault.labels.getString("east"), "RIGHT", goEast);
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
Action goWest = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("go West");
|
|
||||||
goWest();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
JButton west = addDirection(this, MazeDefault.labels.getString("west"), "LEFT", goWest);
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
Action goSouth = new AbstractAction() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
//
|
|
||||||
addStatus("go South");
|
|
||||||
goSouth();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
JButton south = addDirection(this, MazeDefault.labels.getString("south"), "DOWN", goSouth);
|
|
||||||
|
|
||||||
controlMovesPanel.add(north, BorderLayout.NORTH);
|
|
||||||
controlMovesPanel.add(west, BorderLayout.WEST);
|
|
||||||
controlMovesPanel.add(east, BorderLayout.EAST);
|
|
||||||
controlMovesPanel.add(south, BorderLayout.SOUTH);
|
|
||||||
|
|
||||||
JPanel controlPanel = new JPanel();
|
|
||||||
|
|
||||||
controlPanel.add(controlMovesPanel,BorderLayout.LINE_START);
|
|
||||||
statusField = new JTextField("",20);
|
|
||||||
controlPanel.add(statusField, BorderLayout.CENTER);
|
|
||||||
add(controlPanel, BorderLayout.NORTH);
|
|
||||||
|
|
||||||
// control display panel contains controls for display
|
|
||||||
final JPanel controlDisplayPanel = new JPanel(new BorderLayout());
|
|
||||||
|
|
||||||
add(controlDisplayPanel);
|
|
||||||
// zoom , autozoom control
|
|
||||||
add(buildResizeControl());
|
|
||||||
// layers control
|
|
||||||
add(buildLayerControl());
|
|
||||||
add(settings);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel buildResizeControl()
|
|
||||||
{
|
|
||||||
final JCheckBox showAll = new JCheckBox("show all");
|
|
||||||
showAll.addChangeListener(new ChangeListener() {
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
maze.setShowAll(showAll.isSelected());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
final JSlider slider = new JSlider(2, 40);
|
|
||||||
slider.addChangeListener(new ChangeListener() {
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
setWallSize(slider.getValue());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
final JCheckBox autoSlide = new JCheckBox("autoslide");
|
|
||||||
autoSlide.addChangeListener(new ChangeListener() {
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
setAutoSize(autoSlide.isSelected());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JPanel resizecontrol = new JPanel(new FlowLayout());
|
|
||||||
resizecontrol.add(showAll);
|
|
||||||
resizecontrol.add(slider);
|
|
||||||
resizecontrol.add(autoSlide);
|
|
||||||
|
|
||||||
return resizecontrol;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel buildLayerControl()
|
|
||||||
{
|
|
||||||
|
|
||||||
int layers = 10;
|
|
||||||
|
|
||||||
final JTextField layersText = new JTextField("" + layers);
|
|
||||||
|
|
||||||
final JSlider layerSlide = new JSlider( JSlider.HORIZONTAL, 0,layers, 0);
|
|
||||||
layerSlide.addChangeListener(new ChangeListener() {
|
|
||||||
public void stateChanged(ChangeEvent e) {
|
|
||||||
int r = setLayer(layerSlide.getValue());
|
|
||||||
//layerSlide.setMaximum(r);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
layerSlide.setMajorTickSpacing(1);
|
|
||||||
layerSlide.setPaintTicks(true);
|
|
||||||
|
|
||||||
JPanel layerControl = new JPanel(new FlowLayout());
|
|
||||||
layerControl.add(new JLabel("layers"));
|
|
||||||
layerControl.add(layersText);
|
|
||||||
layerControl.add(layerSlide);
|
|
||||||
|
|
||||||
return layerControl;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel getMoveControl() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel getGenerationControl() {
|
|
||||||
return settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
public MazeSettings getSettings() {
|
|
||||||
return settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadRaw() {
|
|
||||||
File infile = new File(params.getSaveDir(), params.getName() + ".raw");
|
File infile = new File(params.getSaveDir(), params.getName() + ".raw");
|
||||||
FileInputStream inputStream = null;
|
FileInputStream inputStream = null;
|
||||||
try {
|
try {
|
||||||
@@ -743,7 +320,7 @@ implements StatusListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadOsm(boolean add, int mulx, int muly) {
|
void loadOsm(boolean add, int mulx, int muly) {
|
||||||
if ( maze != null ) {
|
if ( maze != null ) {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
@@ -777,7 +354,7 @@ implements StatusListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadImc(boolean add) {
|
void loadImc(boolean add) {
|
||||||
if ( maze != null ) {
|
if ( maze != null ) {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
@@ -811,7 +388,7 @@ implements StatusListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadDrawing(boolean add) {
|
void loadDrawing(boolean add) {
|
||||||
if ( maze != null ) {
|
if ( maze != null ) {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
@@ -845,7 +422,7 @@ implements StatusListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadWorldEdit(boolean add) {
|
void loadWorldEdit(boolean add) {
|
||||||
if ( maze != null ) {
|
if ( maze != null ) {
|
||||||
File infile = new File(params.getSaveDir(), params.getName() + ".we");
|
File infile = new File(params.getSaveDir(), params.getName() + ".we");
|
||||||
FileInputStream inputStream = null;
|
FileInputStream inputStream = null;
|
||||||
@@ -880,7 +457,7 @@ implements StatusListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JButton addDirection(final JPanel panel, final String direction, String key, Action goAction) {
|
JButton addDirection(final JPanel panel, final String direction, String key, Action goAction) {
|
||||||
String actionName = "go" + direction;
|
String actionName = "go" + direction;
|
||||||
JButton button = new JButton(direction);
|
JButton button = new JButton(direction);
|
||||||
button.addActionListener(goAction);
|
button.addActionListener(goAction);
|
||||||
@@ -895,13 +472,13 @@ implements StatusListener
|
|||||||
Display display = new Display(model, W, H, params);
|
Display display = new Display(model, W, H, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveWorldEdit() {
|
void saveWorldEdit() {
|
||||||
File outfile = getFileForExtension("we");
|
File outfile = getFileForExtension("we");
|
||||||
if (!outfile.exists()) {
|
if (!outfile.exists()) {
|
||||||
addStatus("Saving we to " + outfile + " ...");
|
addStatus("Saving we to " + outfile + " ...");
|
||||||
try {
|
try {
|
||||||
FileOutputStream out = new FileOutputStream(outfile);
|
FileOutputStream out = new FileOutputStream(outfile);
|
||||||
new MazePersistWorldEdit(model).streamOut("we", out);
|
new MazePersistWorldEdit(layers).streamOut("we", out);
|
||||||
out.close();
|
out.close();
|
||||||
addStatus("... Done.");
|
addStatus("... Done.");
|
||||||
} catch (IOException io) {
|
} catch (IOException io) {
|
||||||
@@ -950,7 +527,7 @@ implements StatusListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int setLayer(int x)
|
int setLayer(int x)
|
||||||
{
|
{
|
||||||
addStatus("set layer " + x);
|
addStatus("set layer " + x);
|
||||||
LabyModel layermodel = layers.getLayer(x);
|
LabyModel layermodel = layers.getLayer(x);
|
||||||
|
|||||||
442
java/org/artisanlogiciel/games/maze/gui/MazeControler.java
Normal file
442
java/org/artisanlogiciel/games/maze/gui/MazeControler.java
Normal file
@@ -0,0 +1,442 @@
|
|||||||
|
package org.artisanlogiciel.games.maze.gui;
|
||||||
|
|
||||||
|
import org.artisanlogiciel.games.maze.MazeParams;
|
||||||
|
import org.artisanlogiciel.games.maze.MazeParamsFixed;
|
||||||
|
import org.artisanlogiciel.games.stl.Maze3dParams;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import javax.swing.event.ChangeEvent;
|
||||||
|
import javax.swing.event.ChangeListener;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
|
||||||
|
public class MazeControler extends JPanel {
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private final Display display;
|
||||||
|
private MazeSettings settings = null;
|
||||||
|
|
||||||
|
JSlider layerSlide = null;
|
||||||
|
|
||||||
|
|
||||||
|
private void setMazeName(String pName) {
|
||||||
|
MazeParamsFixed p = (MazeParamsFixed) display.params;
|
||||||
|
p.setName(pName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JMenu createLoadingMenu() {
|
||||||
|
JMenu loadMenu = new JMenu(MazeDefault.labels.getString("load"));
|
||||||
|
|
||||||
|
final JTextField loadName = new JTextField("newlaby");
|
||||||
|
|
||||||
|
loadMenu.add(loadName);
|
||||||
|
|
||||||
|
Action loadRawAction = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("load raw");
|
||||||
|
|
||||||
|
String filename = loadName.getText();
|
||||||
|
|
||||||
|
if ((filename.length() > 0)) {
|
||||||
|
setMazeName(filename);
|
||||||
|
display.loadRaw();
|
||||||
|
display.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
JButton loadRawButton = new JButton(MazeDefault.labels.getString("load") + " raw");
|
||||||
|
loadRawButton.addActionListener(loadRawAction);
|
||||||
|
loadMenu.add(loadRawButton);
|
||||||
|
|
||||||
|
Action loadImcAction = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("load Imc");
|
||||||
|
|
||||||
|
String filename = loadName.getText();
|
||||||
|
|
||||||
|
if ((filename.length() > 0)) {
|
||||||
|
setMazeName(filename);
|
||||||
|
display.loadImc(false);
|
||||||
|
display.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
JButton loadImcButton = new JButton(MazeDefault.labels.getString("load") + " imc");
|
||||||
|
loadImcButton.addActionListener(loadImcAction);
|
||||||
|
|
||||||
|
loadMenu.add(loadImcButton);
|
||||||
|
|
||||||
|
Action loadDrawingAction = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("load Drawing");
|
||||||
|
|
||||||
|
String filename = loadName.getText();
|
||||||
|
|
||||||
|
if ((filename.length() > 0)) {
|
||||||
|
setMazeName(filename);
|
||||||
|
display.loadDrawing(false);
|
||||||
|
display.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
JButton loadDrawingButton = new JButton(MazeDefault.labels.getString("load") + " Drawing");
|
||||||
|
loadDrawingButton.addActionListener(loadDrawingAction);
|
||||||
|
|
||||||
|
loadMenu.add(loadDrawingButton);
|
||||||
|
|
||||||
|
Action loadOsmAction = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("load Osm");
|
||||||
|
|
||||||
|
String filename = loadName.getText();
|
||||||
|
|
||||||
|
if ((filename.length() > 0)) {
|
||||||
|
setMazeName(filename);
|
||||||
|
// UTM 32T ? approx (long,lat) to meter
|
||||||
|
display.loadOsm(false, 78000, 78000);
|
||||||
|
display.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
loadMenu.add(newLoadButton("osm", loadOsmAction));
|
||||||
|
|
||||||
|
loadMenu.add(newLoadButton("we",
|
||||||
|
new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("load WoldEdit");
|
||||||
|
|
||||||
|
String filename = loadName.getText();
|
||||||
|
|
||||||
|
if ((filename.length() > 0)) {
|
||||||
|
setMazeName(filename);
|
||||||
|
display.loadWorldEdit(false);
|
||||||
|
display.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
));
|
||||||
|
return loadMenu;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JMenu createSavingMenu() {
|
||||||
|
final JTextField saveName = new JTextField("newlaby");
|
||||||
|
|
||||||
|
final JButton savePngButton = newSaveButton("png",
|
||||||
|
new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("save png");
|
||||||
|
setMazeName(saveName.getText());
|
||||||
|
display.savePng();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final JButton saveSvgButton = newSaveButton("svg",
|
||||||
|
new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
display.writeSentence("save svg");
|
||||||
|
setMazeName(saveName.getText());
|
||||||
|
display.saveSvg();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final JButton saveButton = newSaveButton("raw",
|
||||||
|
new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
setMazeName(saveName.getText());
|
||||||
|
MazeParamsFixed p = (MazeParamsFixed) display.params;
|
||||||
|
display.save(p, display.model);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
Action saveImcAction = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
setMazeName(saveName.getText());
|
||||||
|
display.saveImc();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final JButton saveImcButton = newSaveButton("imc", saveImcAction);
|
||||||
|
|
||||||
|
Action saveStlAction = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
setMazeName(saveName.getText());
|
||||||
|
MazeParamsFixed p = (MazeParamsFixed) display.params;
|
||||||
|
display.saveStl(p, display.model, display.stlsettings.createParams());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final JButton saveStlButton = newSaveButton("stl", saveStlAction);
|
||||||
|
|
||||||
|
Action saveTextAction = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
setMazeName(saveName.getText());
|
||||||
|
display.saveText();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
final JButton saveTextButton = newSaveButton("txt", saveTextAction);
|
||||||
|
|
||||||
|
final JButton saveWorleEditButton = newSaveButton("we",
|
||||||
|
new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
setMazeName(saveName.getText());
|
||||||
|
display.saveWorldEdit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
display.stlsettings = new Maze3dSettings(new Maze3dParams());
|
||||||
|
|
||||||
|
JMenu saveMenu = new JMenu(MazeDefault.labels.getString("save"));
|
||||||
|
saveMenu.add(saveName);
|
||||||
|
saveMenu.add(saveSvgButton);
|
||||||
|
saveMenu.add(savePngButton);
|
||||||
|
saveMenu.add(saveButton);
|
||||||
|
saveMenu.add(display.stlsettings);
|
||||||
|
saveMenu.add(saveStlButton);
|
||||||
|
saveMenu.add(saveImcButton);
|
||||||
|
saveMenu.add(saveTextButton);
|
||||||
|
saveMenu.add(saveWorleEditButton);
|
||||||
|
|
||||||
|
return saveMenu;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private JButton newActionButton(String actionName, String format, Action action) {
|
||||||
|
final JButton saveTextButton = new JButton(MazeDefault.labels.getString(actionName) + " " + format);
|
||||||
|
saveTextButton.addActionListener(action);
|
||||||
|
return saveTextButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JButton newSaveButton(String format, Action action) {
|
||||||
|
return newActionButton("save", format, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JButton newLoadButton(String format, Action action) {
|
||||||
|
return newActionButton("load", format, action);
|
||||||
|
}
|
||||||
|
|
||||||
|
private JPanel createResolveQuitBar() {
|
||||||
|
JPanel resolveQuitBar = new JPanel(new FlowLayout());
|
||||||
|
|
||||||
|
JButton buttonCreate = new JButton(MazeDefault.labels.getString("create"));
|
||||||
|
buttonCreate.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
display.recreateModel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
resolveQuitBar.add(buttonCreate);
|
||||||
|
|
||||||
|
JButton resolveButton = new JButton(MazeDefault.labels.getString("resolve"));
|
||||||
|
resolveButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("Resolving");
|
||||||
|
display.resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
resolveQuitBar.add(resolveButton);
|
||||||
|
|
||||||
|
JButton reverseButton = new JButton(MazeDefault.labels.getString("reverse"));
|
||||||
|
reverseButton.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("Reversing");
|
||||||
|
display.mGrow ^= display.reverse(display.mGrow);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
resolveQuitBar.add(reverseButton);
|
||||||
|
|
||||||
|
|
||||||
|
final JButton quitButton = new JButton(MazeDefault.labels.getString("quit"));
|
||||||
|
Action quitAction = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("quit");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
quitButton.addActionListener(quitAction);
|
||||||
|
|
||||||
|
resolveQuitBar.add(quitButton);
|
||||||
|
|
||||||
|
JButton buttonReset = new JButton("reset");//labels.getString("reset"));
|
||||||
|
buttonReset.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
display.resetModel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
resolveQuitBar.add(buttonReset);
|
||||||
|
|
||||||
|
return resolveQuitBar;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MazeControler(Display display, MazeParams params) {
|
||||||
|
// super(new BorderLayout());
|
||||||
|
super();
|
||||||
|
this.display = display;
|
||||||
|
BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS);
|
||||||
|
setLayout(layout);
|
||||||
|
|
||||||
|
JMenuBar menuBar = new JMenuBar();
|
||||||
|
menuBar.add(createSavingMenu());
|
||||||
|
menuBar.add(createLoadingMenu());
|
||||||
|
add(menuBar);
|
||||||
|
|
||||||
|
add(createResolveQuitBar());
|
||||||
|
|
||||||
|
JPanel controlMovesPanel = new JPanel(new BorderLayout());
|
||||||
|
settings = new MazeSettings(params);
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
Action goNorth = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("go North");
|
||||||
|
display.goNorth();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
JButton north = display.addDirection(this, MazeDefault.labels.getString("north"), "UP", goNorth);
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
Action goEast = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("go East");
|
||||||
|
display.goEast();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
JButton east = display.addDirection(this, MazeDefault.labels.getString("east"), "RIGHT", goEast);
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
Action goWest = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("go West");
|
||||||
|
display.goWest();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
JButton west = display.addDirection(this, MazeDefault.labels.getString("west"), "LEFT", goWest);
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
Action goSouth = new AbstractAction() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
//
|
||||||
|
display.addStatus("go South");
|
||||||
|
display.goSouth();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
JButton south = display.addDirection(this, MazeDefault.labels.getString("south"), "DOWN", goSouth);
|
||||||
|
|
||||||
|
controlMovesPanel.add(north, BorderLayout.NORTH);
|
||||||
|
controlMovesPanel.add(west, BorderLayout.WEST);
|
||||||
|
controlMovesPanel.add(east, BorderLayout.EAST);
|
||||||
|
controlMovesPanel.add(south, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
JPanel controlPanel = new JPanel();
|
||||||
|
|
||||||
|
controlPanel.add(controlMovesPanel, BorderLayout.LINE_START);
|
||||||
|
display.statusField = new JTextField("", 20);
|
||||||
|
controlPanel.add(display.statusField, BorderLayout.CENTER);
|
||||||
|
add(controlPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
|
// control display panel contains controls for display
|
||||||
|
final JPanel controlDisplayPanel = new JPanel(new BorderLayout());
|
||||||
|
|
||||||
|
add(controlDisplayPanel);
|
||||||
|
// zoom , autozoom control
|
||||||
|
add(buildResizeControl());
|
||||||
|
// layers control
|
||||||
|
add(buildLayerControl());
|
||||||
|
add(settings);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private JPanel buildResizeControl() {
|
||||||
|
final JCheckBox showAll = new JCheckBox("show all");
|
||||||
|
showAll.addChangeListener(new ChangeListener() {
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
display.maze.setShowAll(showAll.isSelected());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final JSlider slider = new JSlider(2, 40);
|
||||||
|
slider.addChangeListener(new ChangeListener() {
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
display.setWallSize(slider.getValue());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
final JCheckBox autoSlide = new JCheckBox("autoslide");
|
||||||
|
autoSlide.addChangeListener(new ChangeListener() {
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
display.setAutoSize(autoSlide.isSelected());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
JPanel resizecontrol = new JPanel(new FlowLayout());
|
||||||
|
resizecontrol.add(showAll);
|
||||||
|
resizecontrol.add(slider);
|
||||||
|
resizecontrol.add(autoSlide);
|
||||||
|
|
||||||
|
return resizecontrol;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private JPanel buildLayerControl() {
|
||||||
|
|
||||||
|
int layers = 10;
|
||||||
|
|
||||||
|
final JTextField layersText = new JTextField("" + layers);
|
||||||
|
|
||||||
|
layerSlide = new JSlider(JSlider.HORIZONTAL, 0, layers, 0);
|
||||||
|
layerSlide.addChangeListener(new ChangeListener() {
|
||||||
|
public void stateChanged(ChangeEvent e) {
|
||||||
|
int r = display.setLayer(layerSlide.getValue());
|
||||||
|
//layerSlide.setMaximum(r);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
layerSlide.setMajorTickSpacing(1);
|
||||||
|
layerSlide.setPaintTicks(true);
|
||||||
|
|
||||||
|
JPanel layerControl = new JPanel(new FlowLayout());
|
||||||
|
layerControl.add(new JLabel("layers"));
|
||||||
|
layerControl.add(layersText);
|
||||||
|
layerControl.add(layerSlide);
|
||||||
|
|
||||||
|
return layerControl;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLayer() {
|
||||||
|
return layerSlide.getValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
JPanel getMoveControl() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
JPanel getGenerationControl() {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MazeSettings getSettings() {
|
||||||
|
return settings;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,13 +9,20 @@ import java.io.*;
|
|||||||
|
|
||||||
import static org.artisanlogiciel.games.minetest.Material.GRASS_MATERIAL;
|
import static org.artisanlogiciel.games.minetest.Material.GRASS_MATERIAL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* export maze layers as a WorldEdit file
|
||||||
|
*
|
||||||
|
* export only one layer... ( LabyModel ... )
|
||||||
|
* import many layers ( LabyLayers )
|
||||||
|
*/
|
||||||
|
|
||||||
public class MazePersistWorldEdit {
|
public class MazePersistWorldEdit {
|
||||||
|
|
||||||
private LabyModel model;
|
private LabyLayers mLayers;
|
||||||
private WorlEditGenerator generator;
|
private WorlEditGenerator generator;
|
||||||
|
|
||||||
public MazePersistWorldEdit(LabyModel model) {
|
public MazePersistWorldEdit(LabyLayers pLayer) {
|
||||||
this.model = model;
|
this.mLayers = pLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MazePersistWorldEdit() {
|
public MazePersistWorldEdit() {
|
||||||
@@ -30,13 +37,13 @@ public class MazePersistWorldEdit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Node newNode(int x, int y, String material)
|
private Node newNode(int x, int y, int layer, String material)
|
||||||
{
|
{
|
||||||
// x,y,z => x,z,y in minetest
|
// x,y,z => x,z,y in minetest
|
||||||
return new Node(x,0, y, Material.getMaterialByName(material));
|
return new Node(x,layer, y, Material.getMaterialByName(material));
|
||||||
}
|
}
|
||||||
|
|
||||||
void addWalls(int pX, int pY) {
|
void addWalls(int pX, int pY, int pLayer, LabyModel model) {
|
||||||
short walls = model.getWalls(pX, pY);
|
short walls = model.getWalls(pX, pY);
|
||||||
short wdrawn = 0;
|
short wdrawn = 0;
|
||||||
// todo
|
// todo
|
||||||
@@ -46,6 +53,7 @@ public class MazePersistWorldEdit {
|
|||||||
int oy = 0;
|
int oy = 0;
|
||||||
int z = 0;
|
int z = 0;
|
||||||
|
|
||||||
|
// HARDCODED !
|
||||||
String material = GRASS_MATERIAL;
|
String material = GRASS_MATERIAL;
|
||||||
|
|
||||||
int x = ox + (pX * w);
|
int x = ox + (pX * w);
|
||||||
@@ -55,7 +63,7 @@ public class MazePersistWorldEdit {
|
|||||||
//if ((pY == 0) && LabyModel.isFlagSet(walls, Brick.UP)) {
|
//if ((pY == 0) && LabyModel.isFlagSet(walls, Brick.UP)) {
|
||||||
if (LabyModel.isFlagSet(walls, Brick.UP)) {
|
if (LabyModel.isFlagSet(walls, Brick.UP)) {
|
||||||
for ( int dx = 0; dx < w; dx++) {
|
for ( int dx = 0; dx < w; dx++) {
|
||||||
addNode(newNode(x + dx, y,material));
|
addNode(newNode(x + dx, y, pLayer, material));
|
||||||
}
|
}
|
||||||
wdrawn |= Brick.UP;
|
wdrawn |= Brick.UP;
|
||||||
}
|
}
|
||||||
@@ -78,7 +86,7 @@ public class MazePersistWorldEdit {
|
|||||||
//if ((pX == 0) && LabyModel.isFlagSet(walls, Brick.LEFT)) {
|
//if ((pX == 0) && LabyModel.isFlagSet(walls, Brick.LEFT)) {
|
||||||
if (LabyModel.isFlagSet(walls, Brick.LEFT)) {
|
if (LabyModel.isFlagSet(walls, Brick.LEFT)) {
|
||||||
for (int dy = 0; dy < h; dy ++) {
|
for (int dy = 0; dy < h; dy ++) {
|
||||||
addNode(newNode(x, y + dy, material));
|
addNode(newNode(x, y + dy, pLayer, material));
|
||||||
}
|
}
|
||||||
wdrawn |= Brick.LEFT;
|
wdrawn |= Brick.LEFT;
|
||||||
}
|
}
|
||||||
@@ -96,16 +104,22 @@ public class MazePersistWorldEdit {
|
|||||||
// first raw format, not smart.
|
// first raw format, not smart.
|
||||||
DataOutputStream dataOut = new DataOutputStream(pOut);
|
DataOutputStream dataOut = new DataOutputStream(pOut);
|
||||||
dataOut.flush();
|
dataOut.flush();
|
||||||
for (int y = 0; y < model.getHeight(); y++) {
|
for (int layer = mLayers.getMin(); layer <= mLayers.getMax(); layer ++) {
|
||||||
for (int x = 0; x < model.getWidth(); x++) {
|
LabyModel model = mLayers.getLayer(layer);
|
||||||
addWalls(x,y);
|
if ( model != null )
|
||||||
|
{
|
||||||
|
for (int y = 0; y < model.getHeight(); y++) {
|
||||||
|
for (int x = 0; x < model.getWidth(); x++) {
|
||||||
|
addWalls(x, y, layer, model);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
generator.writeEnd();
|
generator.writeEnd();
|
||||||
dataOut.write(builder.toString().getBytes());
|
dataOut.write(builder.toString().getBytes());
|
||||||
dataOut.flush();
|
dataOut.flush();
|
||||||
} else {
|
} else {
|
||||||
throw new IOException("Format " + pFormat + " Not yet implemented.");
|
throw new IOException("Format " + pFormat + " Not supported or Not yet implemented.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +141,7 @@ public class MazePersistWorldEdit {
|
|||||||
for (int level = world.getMin(); level <= world.getMax(); level++) {
|
for (int level = world.getMin(); level <= world.getMax(); level++) {
|
||||||
Slice ground = world.getSlice(level);
|
Slice ground = world.getSlice(level);
|
||||||
if (ground != null) {
|
if (ground != null) {
|
||||||
model = getModelFromSlice(ground);
|
LabyModel model = getModelFromSlice(ground);
|
||||||
model.setOnewaywall(true);
|
model.setOnewaywall(true);
|
||||||
layers.addLabyModel(level, model);
|
layers.addLabyModel(level, model);
|
||||||
System.out.println(model);
|
System.out.println(model);
|
||||||
@@ -176,7 +190,7 @@ public class MazePersistWorldEdit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
model = new LabyModel(width,height, t);
|
LabyModel model = new LabyModel(width,height, t);
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,7 +1,13 @@
|
|||||||
package org.artisanlogiciel.games.minetest;
|
package org.artisanlogiciel.games.minetest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [min,max] range with bounds included.
|
||||||
|
*/
|
||||||
public class Range {
|
public class Range {
|
||||||
|
|
||||||
|
// included
|
||||||
int min;
|
int min;
|
||||||
|
// included
|
||||||
int max;
|
int max;
|
||||||
|
|
||||||
public int getMin() {
|
public int getMin() {
|
||||||
@@ -19,6 +25,12 @@ public class Range {
|
|||||||
max = -1;
|
max = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Range(int pMin, int pMax)
|
||||||
|
{
|
||||||
|
min = pMin;
|
||||||
|
max = pMax;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isEmpty()
|
public boolean isEmpty()
|
||||||
{
|
{
|
||||||
return ( min > max );
|
return ( min > max );
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package org.artisanlogiciel.games.minetest;
|
package org.artisanlogiciel.games.minetest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generate directly lua maps ( no intermediate LuaObject ).
|
* generate directly lua maps text ( no intermediate LuaObject ).
|
||||||
*/
|
*/
|
||||||
public class WorlEditGenerator
|
public class WorlEditGenerator
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user