display seed, create subpackage
- display seed value ( can't be set yet ) - move MazeSetting in gui sub package
This commit is contained in:
@@ -23,7 +23,6 @@ import java.io.FileOutputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
@@ -32,6 +31,7 @@ import javax.swing.*;
|
|||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
|
|
||||||
|
import org.artisanlogiciel.games.maze.gui.MazeSettings;
|
||||||
import org.artisanlogiciel.games.stl.Wall3d;
|
import org.artisanlogiciel.games.stl.Wall3d;
|
||||||
import org.artisanlogiciel.util.UTF8Control;
|
import org.artisanlogiciel.util.UTF8Control;
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ public class Display extends JFrame {
|
|||||||
// to please eclipse, not supposed to be serialized
|
// to please eclipse, not supposed to be serialized
|
||||||
private static final long serialVersionUID = 8500214871372184418L;
|
private static final long serialVersionUID = 8500214871372184418L;
|
||||||
|
|
||||||
final static ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", Locale.getDefault(), Display.class.getClassLoader(), new UTF8Control());
|
public final static ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", Locale.getDefault(), Display.class.getClassLoader(), new UTF8Control());
|
||||||
|
|
||||||
MazeComponent maze;
|
MazeComponent maze;
|
||||||
MazeControler controler;
|
MazeControler controler;
|
||||||
@@ -97,7 +97,7 @@ public class Display extends JFrame {
|
|||||||
void recreateModel() {
|
void recreateModel() {
|
||||||
// recreate labyrinth
|
// recreate labyrinth
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
params = controler.getSettings().getParams();
|
params = controler.getSettings().resetParams();
|
||||||
// DON'T keep current model...
|
// DON'T keep current model...
|
||||||
// TODO control SEED.
|
// TODO control SEED.
|
||||||
model = new LabyModel(params);
|
model = new LabyModel(params);
|
||||||
@@ -120,7 +120,7 @@ public class Display extends JFrame {
|
|||||||
void resetModel() {
|
void resetModel() {
|
||||||
// recreate labyrinth
|
// recreate labyrinth
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
params = controler.getSettings().getParams();
|
params = controler.getSettings().resetParams();
|
||||||
model = new LabyModel(params);
|
model = new LabyModel(params);
|
||||||
maze.resetWallsProvider(model);
|
maze.resetWallsProvider(model);
|
||||||
model.setMazeListener(maze);
|
model.setMazeListener(maze);
|
||||||
@@ -301,58 +301,6 @@ public class Display extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MazeSettings extends JPanel {
|
|
||||||
MazeParams params;
|
|
||||||
|
|
||||||
JTextField textWidth = null;
|
|
||||||
JTextField textHeight = null;
|
|
||||||
JTextField textDepth = null;
|
|
||||||
|
|
||||||
// TODO set width and height and depth of maze with gui
|
|
||||||
public MazeSettings(MazeParams params) {
|
|
||||||
super();
|
|
||||||
this.params = params;
|
|
||||||
createSettingsGui();
|
|
||||||
}
|
|
||||||
|
|
||||||
void createSettingsGui() {
|
|
||||||
if (params != null) {
|
|
||||||
JButton buttonReset = new JButton("reset");//labels.getString("reset"));
|
|
||||||
buttonReset.addActionListener(new ActionListener() {
|
|
||||||
public void actionPerformed(ActionEvent evt) {
|
|
||||||
resetModel();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
add(buttonReset);
|
|
||||||
|
|
||||||
}
|
|
||||||
if (params != null) {
|
|
||||||
JLabel widthLabel = new JLabel(labels.getString("width"));
|
|
||||||
textWidth = new JTextField("0" + params.getWidth());
|
|
||||||
add(widthLabel);
|
|
||||||
add(textWidth);
|
|
||||||
JLabel heightLabel = new JLabel(labels.getString("height"));
|
|
||||||
textHeight = new JTextField("0" + params.getHeight());
|
|
||||||
add(heightLabel);
|
|
||||||
add(textHeight);
|
|
||||||
JLabel depthLabel = new JLabel(labels.getString("depth"));
|
|
||||||
textDepth = new JTextField("0" + params.getMaxDepth());
|
|
||||||
add(depthLabel);
|
|
||||||
add(textDepth);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public MazeParams getParams() {
|
|
||||||
return new MazeParamsFixed(params.getSaveDir(),
|
|
||||||
Integer.parseInt(textWidth.getText()),
|
|
||||||
Integer.parseInt(textHeight.getText()),
|
|
||||||
Integer.parseInt(textDepth.getText()),
|
|
||||||
new Random().nextLong()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private class MazeControler extends JPanel {
|
private class MazeControler extends JPanel {
|
||||||
/**
|
/**
|
||||||
@@ -457,6 +405,14 @@ public class Display extends JFrame {
|
|||||||
|
|
||||||
resolveQuitBar.add(quitButton);
|
resolveQuitBar.add(quitButton);
|
||||||
|
|
||||||
|
JButton buttonReset = new JButton("reset");//labels.getString("reset"));
|
||||||
|
buttonReset.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent evt) {
|
||||||
|
resetModel();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
resolveQuitBar.add(buttonReset);
|
||||||
|
|
||||||
return resolveQuitBar;
|
return resolveQuitBar;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
57
java/org/artisanlogiciel/games/maze/gui/MazeSettings.java
Normal file
57
java/org/artisanlogiciel/games/maze/gui/MazeSettings.java
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
package org.artisanlogiciel.games.maze.gui;
|
||||||
|
|
||||||
|
import org.artisanlogiciel.games.Display;
|
||||||
|
import org.artisanlogiciel.games.MazeParams;
|
||||||
|
import org.artisanlogiciel.games.MazeParamsFixed;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class MazeSettings extends JPanel {
|
||||||
|
MazeParams params;
|
||||||
|
|
||||||
|
JTextField textWidth = null;
|
||||||
|
JTextField textHeight = null;
|
||||||
|
JTextField textDepth = null;
|
||||||
|
JTextField textSeed = null;
|
||||||
|
|
||||||
|
// TODO set width and height and depth of maze with gui
|
||||||
|
public MazeSettings(MazeParams params) {
|
||||||
|
super();
|
||||||
|
this.params = params;
|
||||||
|
createSettingsGui();
|
||||||
|
}
|
||||||
|
|
||||||
|
void createSettingsGui() {
|
||||||
|
if (params != null) {
|
||||||
|
JLabel widthLabel = new JLabel(Display.labels.getString("width"));
|
||||||
|
textWidth = new JTextField("0" + params.getWidth());
|
||||||
|
add(widthLabel);
|
||||||
|
add(textWidth);
|
||||||
|
JLabel heightLabel = new JLabel(Display.labels.getString("height"));
|
||||||
|
textHeight = new JTextField("0" + params.getHeight());
|
||||||
|
add(heightLabel);
|
||||||
|
add(textHeight);
|
||||||
|
JLabel depthLabel = new JLabel(Display.labels.getString("depth"));
|
||||||
|
textDepth = new JTextField("0" + params.getMaxDepth());
|
||||||
|
add(depthLabel);
|
||||||
|
add(textDepth);
|
||||||
|
JLabel seedLabel = new JLabel(Display.labels.getString("seed"));
|
||||||
|
textSeed = new JTextField( "" + params.getSeed(),16);
|
||||||
|
add(seedLabel);
|
||||||
|
add(textSeed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public MazeParams resetParams() {
|
||||||
|
params = new MazeParamsFixed(params.getSaveDir(),
|
||||||
|
Integer.parseInt(textWidth.getText()),
|
||||||
|
Integer.parseInt(textHeight.getText()),
|
||||||
|
Integer.parseInt(textDepth.getText()),
|
||||||
|
new Random().nextLong()
|
||||||
|
);
|
||||||
|
textSeed.setText("" + params.getSeed());
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -9,4 +9,5 @@ resolve = Resolve
|
|||||||
create = Create
|
create = Create
|
||||||
save = Save
|
save = Save
|
||||||
quit = Quit
|
quit = Quit
|
||||||
title = A Maz ing
|
title = A Maz ing
|
||||||
|
seed = seed
|
||||||
@@ -9,4 +9,5 @@ resolve = Résoudre
|
|||||||
create = Créer
|
create = Créer
|
||||||
save = Sauver
|
save = Sauver
|
||||||
quit = Quitter
|
quit = Quitter
|
||||||
title = La Bireinte
|
title = La Bireinte
|
||||||
|
seed = graine
|
||||||
Reference in New Issue
Block a user