added correct colors in LobbyMenu

This commit is contained in:
Johannes Schmelz 2024-11-26 23:01:55 +01:00
parent 156e76fe0a
commit c8b69efca2
3 changed files with 29 additions and 14 deletions

View File

@ -25,6 +25,7 @@ import com.simsilica.lemur.style.ElementId;
import pp.dialog.Dialog;
import pp.monopoly.client.MonopolyApp;
import pp.monopoly.game.server.PlayerColor;
import pp.monopoly.message.client.PlayerReady;
import pp.monopoly.notification.Sound;
@ -171,7 +172,7 @@ public class LobbyMenu extends Dialog {
app.getGuiNode().attachChild(lowerRightMenu);
// Add a colored circle between the input field and the dropdown menu
circle = createCircle( ColorRGBA.Red); // 50 is the diameter, Red is the color
circle = createCircle(); // 50 is the diameter, Red is the color
circle.setLocalTranslation(new Vector3f(
(app.getCamera().getWidth()) / 2, // Center horizontally
(app.getCamera().getHeight() / 2) - 90, // Adjust Y position
@ -205,19 +206,33 @@ public class LobbyMenu extends Dialog {
app.getGuiNode().attachChild(background);
}
private Geometry createCircle(ColorRGBA color) {
private Geometry createCircle() {
Sphere sphere = new Sphere(90,90,60.0f);
Geometry circleGeometry = new Geometry("Circle", sphere);
// Create a material with a solid color
Material material = new Material(app.getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
material.setColor("Color", color); // Set the desired color
material.setColor("Color", idToColor()); // Set the desired color
circleGeometry.setMaterial(material);
return circleGeometry;
}
private ColorRGBA idToColor() {
switch (app.getId()+1) {
case 1: return PlayerColor.CYAN.getColor();
case 2: return PlayerColor.YELLOW.getColor();
case 3: return PlayerColor.RED.getColor();
case 4: return PlayerColor.PINK.getColor();
case 5: return PlayerColor.GREEN.getColor();
case 6: return PlayerColor.PURPLE.getColor();
default:
return null;
}
}
/**
* Schaltet den "Bereit"-Status um.
*/

View File

@ -79,12 +79,12 @@ public class Player implements FieldVisitor<Void>{
public PlayerColor getColor() {
switch ((id%6)+1) {
case 1: return PlayerColor.BLUE;
case 2: return PlayerColor.GREEN_DARK;
case 3: return PlayerColor.GREEN_LIGHT;
case 1: return PlayerColor.CYAN;
case 2: return PlayerColor.YELLOW;
case 3: return PlayerColor.RED;
case 4: return PlayerColor.PINK;
case 5: return PlayerColor.RED;
case 6: return PlayerColor.YELLOW;
case 5: return PlayerColor.GREEN;
case 6: return PlayerColor.PURPLE;
default:
return null;

View File

@ -6,12 +6,12 @@ import com.jme3.math.ColorRGBA;
* Enum representing six distinct colors for players in the game.
*/
public enum PlayerColor {
GREEN_LIGHT(new ColorRGBA(0 / 255f, 204 / 255f, 0 / 255f, 1)), // Hex: 00cc00
RED(new ColorRGBA(255 / 255f, 0 / 255f, 0 / 255f, 1)), // Hex: ff0000
BLUE(new ColorRGBA(0 / 255f, 0 / 255f, 204 / 255f, 1)), // Hex: 0000cc
PINK(new ColorRGBA(255 / 255f, 77 / 255f, 166 / 255f, 1)), // Hex: ff4da6
GREEN_DARK(new ColorRGBA(0 / 255f, 102 / 255f, 0 / 255f, 1)), // Hex: 006600
YELLOW(new ColorRGBA(255 / 255f, 255 / 255f, 0 / 255f, 1)); // Hex: ffff00
CYAN(new ColorRGBA(1 / 255f, 190 / 255f, 254 / 255f, 1)),
YELLOW(new ColorRGBA(255 / 255f, 255 / 255f, 0 / 255f, 1)),
RED(new ColorRGBA(255 / 255f, 0 / 255f, 0 / 255f, 1)),
PINK(new ColorRGBA(255 / 255f, 77 / 255f, 166 / 255f, 1)),
GREEN(new ColorRGBA(0 / 255f, 204 / 255f, 0 / 255f, 1)),
PURPLE(new ColorRGBA(143 / 255f, 0 / 255f, 255 / 255f, 1));
private final ColorRGBA color;