Started implementing the changes of the images depending on day night and role

This commit is contained in:
Seraina 2022-05-14 12:03:10 +02:00
parent 76ab7535b5
commit 119a456968
19 changed files with 46 additions and 38 deletions

View File

@ -3,3 +3,5 @@ serai
serai serai
Jonas of Istanbul Jonas of Istanbul
serai serai
serai
serai

View File

@ -19,7 +19,7 @@ public class BudaLogConfig {
LoggerContext ctx = (LoggerContext) LogManager.getContext(false); LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
Configuration config = ctx.getConfiguration(); Configuration config = ctx.getConfiguration();
LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME); LoggerConfig loggerConfig = config.getLoggerConfig(LogManager.ROOT_LOGGER_NAME);
loggerConfig.setLevel(Level.DEBUG); // change level here loggerConfig.setLevel(Level.ERROR); // change level here
ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig. ctx.updateLoggers(); // This causes all Loggers to refetch information from their LoggerConfig.
} }

View File

@ -6,6 +6,7 @@ import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GUI; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GUI;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GameStateModel; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GameStateModel;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ChatApp; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ChatApp;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.Sprites;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatController; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.chat.ChatController;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.GameController; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.game.GameController;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeApp; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.lounge.LoungeApp;
@ -350,12 +351,16 @@ public class Client {
case GuiParameters.night: //ClientGameInfoHandler; case GuiParameters.night: //ClientGameInfoHandler;
gameStateModel.setDayClone(false); gameStateModel.setDayClone(false);
LOGGER.debug("----------------Night, Your role is:" + gameStateModel.getYourRole() + gameStateModel); LOGGER.debug("----------------Night, Your role is:" + gameStateModel.getYourRole() + gameStateModel);
Sprites.setNightSprites(gameStateModel.getPassengerTrainClone()[1], GameController.getGameStateModel().getKickedOff());
chatApp.getGameController().updateGameSprites();
chatApp.getGameController().setNoiseButtonInvisible(); chatApp.getGameController().setNoiseButtonInvisible();
chatApp.getGameController().setVoteButtonVisibilityNight(gameStateModel); chatApp.getGameController().setVoteButtonVisibilityNight(gameStateModel);
break; break;
case GuiParameters.day: //ClientGameInfoHandler case GuiParameters.day: //ClientGameInfoHandler
gameStateModel.setDayClone(true); gameStateModel.setDayClone(true);
LOGGER.debug("----------------Day, Your role is:" + gameStateModel.getYourRole()+ gameStateModel); LOGGER.debug("----------------Day, Your role is:" + gameStateModel.getYourRole()+ gameStateModel);
Sprites.setDaySprites(gameStateModel.getPassengerTrainClone()[1], GameController.getGameStateModel().getKickedOff());
chatApp.getGameController().updateGameSprites();
chatApp.getGameController().setNoiseButtonVisible(); chatApp.getGameController().setNoiseButtonVisible();
chatApp.getGameController().setVoteButtonVisibilityDay(gameStateModel); chatApp.getGameController().setVoteButtonVisibilityDay(gameStateModel);
break; break;

View File

@ -9,7 +9,6 @@ import javafx.util.Duration;
public class BGAnimation extends Transition { public class BGAnimation extends Transition {
ImageView imageView; ImageView imageView;
private static final Image bgFull = new Image("ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/Day/BG_small.jpg");
int index; int index;
int lastIndex; int lastIndex;
@ -19,7 +18,7 @@ public class BGAnimation extends Transition {
this.imageView = imageView; this.imageView = imageView;
imageView.setFitHeight(1950); imageView.setFitHeight(1950);
imageView.setFitWidth(6667.968); imageView.setFitWidth(6667.968);
imageView.setImage(bgFull); imageView.setImage(Sprites.getBg());
setCycleDuration(duration); setCycleDuration(duration);
setInterpolator(Interpolator.DISCRETE); setInterpolator(Interpolator.DISCRETE);
@ -27,6 +26,7 @@ public class BGAnimation extends Transition {
@Override @Override
protected void interpolate(double frac) { protected void interpolate(double frac) {
imageView.setImage(Sprites.getBg());
if(index == lastIndex) { if(index == lastIndex) {
index = 0; index = 0;
imageView.setX(0); imageView.setX(0);

View File

@ -157,6 +157,9 @@ public class ChatApp extends Application {
this.setGameC(gameController); this.setGameC(gameController);
gameC.setClient(cModel); gameC.setClient(cModel);
gameC.setGameStateModel(GameController.getGameStateModel()); gameC.setGameStateModel(GameController.getGameStateModel());
Sprites.setDaySprites(GameController.getGameStateModel().getPassengerTrainClone()[1], GameController.getGameStateModel().getKickedOff());
SpritesDay.setBells();
SpritesDay.setWheels();
try { try {
URL chatResource = ChatApp.class.getResource("chat/ChatView.fxml"); URL chatResource = ChatApp.class.getResource("chat/ChatView.fxml");
URL gameResource = ChatApp.class.getResource("game/GameDayAll.fxml"); URL gameResource = ChatApp.class.getResource("game/GameDayAll.fxml");

View File

@ -68,11 +68,15 @@ public class GameStateModel {
* @param yourRole the role to set this role to * @param yourRole the role to set this role to
*/ */
public void setYourRole(String yourRole) { public void setYourRole(String yourRole) {
try {
if (yourRole.equals("h") || yourRole.equals("g") || yourRole.equals("s")) { if (yourRole.equals("h") || yourRole.equals("g") || yourRole.equals("s")) {
this.yourRole = yourRole; this.yourRole = yourRole;
} else { } else {
this.yourRole = "h"; this.yourRole = "h";
} }
} catch (Exception e) {
LOGGER.warn("YourRole:" + e.getMessage());
}
} }

View File

@ -4,6 +4,7 @@ import static javafx.scene.AccessibleRole.PARENT;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ChatApp; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ChatApp;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GameStateModel; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.GameStateModel;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.Sprites;
import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters; import ch.unibas.dmi.dbis.cs108.multiplayer.helpers.GuiParameters;
import ch.unibas.dmi.dbis.cs108.BudaLogConfig; import ch.unibas.dmi.dbis.cs108.BudaLogConfig;
import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel; import ch.unibas.dmi.dbis.cs108.multiplayer.client.gui.ClientModel;
@ -37,24 +38,10 @@ public class GameController implements Initializable {
private static GameStateModel gameStateModel; private static GameStateModel gameStateModel;
Image[] bells = new Image[17]; Image[] bells = Sprites.getBells();
public GameController() { public GameController() {
super(); super();
try {
for (int i = 1; i <= 17; i++) {
String url;
if (i < 10) {
url =
"ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/Day/Bell/Image000" + i + ".png";
} else {
url = "ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/Day/Bell/Image00" + i + ".png";
}
bells[i-1] = new Image(url);
}
} catch (Exception e) {
e.printStackTrace();
}
} }
//TODO(Seraina, Sebi): Same issue as ChatController? do with setters? //TODO(Seraina, Sebi): Same issue as ChatController? do with setters?
@ -139,6 +126,23 @@ public class GameController implements Initializable {
@FXML @FXML
private AnchorPane chatAreaGame; private AnchorPane chatAreaGame;
public void updateGameSprites(){
Platform.runLater(new Runnable() {
@Override
public void run() {
try{
room0ImageView.setImage(Sprites.getARoom(0));
room1ImageView.setImage(Sprites.getARoom(1));
room2ImageView.setImage(Sprites.getARoom(2));
room3ImageView.setImage(Sprites.getARoom(3));
room4ImageView.setImage(Sprites.getARoom(4));
room5ImageView.setImage(Sprites.getARoom(5));
} catch (Exception e) {
LOGGER.info(e.getMessage());
}
}
});
}
public void addToChatArea(Node n) { public void addToChatArea(Node n) {
chatAreaGame.getChildren().add(n); chatAreaGame.getChildren().add(n);
@ -538,15 +542,6 @@ public class GameController implements Initializable {
}); });
} }
/**
* loads the notification Bell from resource
* @return the Image node containing the BellImage
*/
public Image loadBellImage() {
Image bell = new Image("ch/unibas/dmi/dbis/cs108/multiplayer/client/gui/game/DayOpen/bell.png");
return bell;
}
/** /**
* Adds an image of a bell on top of button0 * Adds an image of a bell on top of button0
*/ */
@ -561,7 +556,7 @@ public class GameController implements Initializable {
bell.play(); bell.play();
} }
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); e.printStackTrace();
} }
} }
}); });
@ -582,7 +577,7 @@ public class GameController implements Initializable {
bell.play(); bell.play();
} }
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); e.printStackTrace();
} }
} }
}); });
@ -602,8 +597,7 @@ public class GameController implements Initializable {
bell.play(); bell.play();
} }
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); e.printStackTrace();
;
} }
} }
}); });
@ -623,7 +617,7 @@ public class GameController implements Initializable {
bell.play(); bell.play();
} }
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); e.printStackTrace();
} }
} }
}); });
@ -643,7 +637,7 @@ public class GameController implements Initializable {
bell.play(); bell.play();
} }
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); e.printStackTrace();
} }
} }
}); });
@ -663,7 +657,7 @@ public class GameController implements Initializable {
bell.play(); bell.play();
} }
} catch (Exception e) { } catch (Exception e) {
LOGGER.debug(e.getMessage()); e.printStackTrace();
} }
} }
}); });

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB