changed pathfinding for csv and txt files
parent
19fe8fee34
commit
18d440bdbc
|
@ -128,7 +128,11 @@ public class HitoriMain extends JFrame implements ActionListener{
|
|||
buttons[i][j] = null;
|
||||
}
|
||||
JButton[][] buttons0 = makeButtonArray(data);
|
||||
try {
|
||||
GameGUI.paintGame(filepath, buttons0, colors, madeMoves, data);
|
||||
} catch (FileNotFoundException s) {
|
||||
System.out.println("File not found: " + s.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import de.hs_mannheim.informatik.pr2projekt.domain.HitoriMain;
|
|||
|
||||
public class GameGUI {
|
||||
|
||||
public static void paintGame(String[] filepath, JButton[][] buttons, String[][] colors, Stack<String> madeMoves, String[][] data){
|
||||
public static void paintGame(String[] filepath, JButton[][] buttons, String[][] colors, Stack<String> madeMoves, String[][] data) throws FileNotFoundException{
|
||||
JFrame frame = new JFrame();
|
||||
int num = buttons.length;
|
||||
JPanel gameGrid = new JPanel(new GridLayout(num,num,0,0));
|
||||
|
@ -40,7 +40,11 @@ public class GameGUI {
|
|||
JButton b0 = new JButton("Aufgeben");
|
||||
b0.addActionListener(e -> {
|
||||
frame.dispose();
|
||||
try {
|
||||
MenuGUI.getPath(filepath);
|
||||
} catch (FileNotFoundException i) {
|
||||
System.out.println("File not found: " + i.getMessage());
|
||||
}
|
||||
});
|
||||
JButton b1 = new JButton("Zurück");
|
||||
b1.addActionListener(e -> {GameGUI.backOneStep(madeMoves, buttons, colors, gameGrid);});
|
||||
|
@ -201,7 +205,11 @@ public class GameGUI {
|
|||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
try {
|
||||
MenuGUI.getPath(filepath);
|
||||
} catch (FileNotFoundException i) {
|
||||
System.out.println("File not found: " + i.getMessage());
|
||||
}
|
||||
});
|
||||
filepath[0] = "";
|
||||
filepath[1] = "";
|
||||
|
|
|
@ -20,6 +20,8 @@ import de.hs_mannheim.informatik.pr2projekt.domain.HitoriMain;
|
|||
public class HighscoreGUI {
|
||||
|
||||
public static void highscoreScreen(String[] filepath){
|
||||
String currentWorkingDir = System.getProperty("user.dir");
|
||||
System.out.println("Current working directory: " + currentWorkingDir);
|
||||
JFrame frame = new JFrame("Highscores");
|
||||
JPanel highscorePanel = new JPanel(new BorderLayout());
|
||||
JPanel buttonPanel = new JPanel(new GridLayout(7,1,10,10));
|
||||
|
@ -54,7 +56,11 @@ public class HighscoreGUI {
|
|||
JButton b = new JButton("Zurück");
|
||||
b.addActionListener(e -> {
|
||||
frame.dispose();
|
||||
try {
|
||||
MenuGUI.getPath(filepath);
|
||||
} catch (FileNotFoundException i) {
|
||||
System.out.println("File not found: " + i.getMessage());
|
||||
}
|
||||
});
|
||||
buttonPanel.add(b);
|
||||
frame.setVisible(true);
|
||||
|
@ -88,6 +94,8 @@ public class HighscoreGUI {
|
|||
}
|
||||
|
||||
public static void showHighscores(String[] filepath, String path){
|
||||
String currentWorkingDir = System.getProperty("user.dir");
|
||||
System.out.println("Current working directory: " + currentWorkingDir);
|
||||
JFrame frame = new JFrame("Highscore");
|
||||
JPanel mainPanel = new JPanel(new BorderLayout());
|
||||
File file = new File(path);
|
||||
|
@ -126,7 +134,11 @@ public class HighscoreGUI {
|
|||
JButton b = new JButton("Zurück");
|
||||
b.addActionListener(e ->{
|
||||
frame.dispose();
|
||||
try {
|
||||
MenuGUI.getPath(filepath);
|
||||
} catch (FileNotFoundException s) {
|
||||
System.out.println("File not found: " + s.getMessage());
|
||||
}
|
||||
});
|
||||
mainPanel.add(highscorePanel, BorderLayout.CENTER);
|
||||
frame.add(mainPanel);
|
||||
|
|
|
@ -12,7 +12,8 @@ import javax.swing.JPanel;
|
|||
|
||||
public class MenuGUI {
|
||||
|
||||
public static void getPath(String[] filepath){
|
||||
public static void getPath(String[] filepath) throws FileNotFoundException{
|
||||
|
||||
String[] filepath0 = new String[2];
|
||||
JFrame frame = new JFrame("Hitori");
|
||||
JPanel menuPanel = new JPanel(new BorderLayout());
|
||||
|
@ -34,12 +35,12 @@ public class MenuGUI {
|
|||
b0.addActionListener(e -> {
|
||||
int j = count[0];
|
||||
String[] paths = {
|
||||
"Hitori_Spielfelder2/Hitori4x4_leicht.csv",
|
||||
"Hitori_Spielfelder2/Hitori5x5leicht.csv",
|
||||
"Hitori_Spielfelder2/Hitori8x8leicht.csv",
|
||||
"Hitori_Spielfelder2/Hitori8x8medium.csv",
|
||||
"Hitori_Spielfelder2/Hitori10x10medium.csv",
|
||||
"Hitori_Spielfelder2/Hitori15x15_medium.csv"
|
||||
"Hitori_Spielfelder/Hitori4x4_leicht.csv",
|
||||
"Hitori_Spielfelder/Hitori5x5leicht.csv",
|
||||
"Hitori_Spielfelder/Hitori8x8leicht.csv",
|
||||
"Hitori_Spielfelder/Hitori8x8medium.csv",
|
||||
"Hitori_Spielfelder/Hitori10x10medium.csv",
|
||||
"Hitori_Spielfelder/Hitori15x15_medium.csv"
|
||||
};
|
||||
filepath0[0] = paths[j];
|
||||
filepath0[1] = row[0];
|
||||
|
|
Loading…
Reference in New Issue