Skip to content

Commit

Permalink
Actually fixed issue ucsb-cs56-projects#47; can use any file path but…
Browse files Browse the repository at this point in the history
… only takes pngs
  • Loading branch information
Matthew Pontarolo committed Mar 13, 2018
1 parent 50f26f3 commit e9a290e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public class CardEditor extends BorderPane {
public CardEditor(Card c) {
//sets path variable to directory of the people pictures
path = System.getProperty("user.dir");
//Hardcode path if all else fails
path = path + "/src/edu/ucsb/cs56/projects/games/name_memorization/people/";

isPicture = false;
Expand Down Expand Up @@ -114,10 +115,6 @@ public void handle(ActionEvent event) {

String name = selectedFile.getName();
path = selectedFile.getPath();
//path = path + name; // path should now contain full location of chosen pic

System.out.println("name: " + name);
System.out.println("path: " + path);

front.setVisible(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ private BufferedImage resizeImage(BufferedImage originalImage, int width, int he
*/
public Label getPic() {
//getPic is only called if isPic is true, so side1 would contain picture path
System.out.println(card.getSide1());
System.out.println(new File(card.getSide1()).toURI().toString());
Image image = new Image(new File(card.getSide1()).toURI().toString());
ImageView iv = new ImageView(image);
iv.setFitHeight(100);
Expand Down
11 changes: 5 additions & 6 deletions src/edu/ucsb/cs56/projects/games/name_memorization/NameGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public void handle(ActionEvent event) {
d.editCard(c, side1, side2);
current = d.size() - 1;
Card h = (Card) d.get(current);
cardText.setText(h.getSide1());
setPrint(h, 1);

if(h.isPic()) {
setPic(h);
Expand Down Expand Up @@ -511,12 +511,11 @@ public void handle(ActionEvent event) {
if (h.isPic()) {
setPic(h);
} else {
cardText.setText(h.getSide1());
if (h.isFavorite() == false) {
setPrint(h, 1);
if (!h.isFavorite()) {
Region region = ( Region ) cardText.lookup( ".content" );
region.setBackground( new Background( new BackgroundFill( Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY ) ) );
}
if (h.isFavorite() == true) {
} else {
Region region = ( Region ) cardText.lookup( ".content" );
region.setBackground( new Background( new BackgroundFill( Color.YELLOW, CornerRadii.EMPTY, Insets.EMPTY ) ) );
}
Expand All @@ -529,7 +528,7 @@ public void handle(ActionEvent event) {
scoreLabelQuiz.setText("Score: " + Integer.toString(scoreQuiz));
} else {
correctQuiz.setVisible(true);
cardText.setText(h.getSide2());
setPrint(h, 2);
}
}
};
Expand Down
Binary file not shown.

0 comments on commit e9a290e

Please sign in to comment.