Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/net/deckserver/JolAdmin.java
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ public static Set<String> getGameNames() {
public static synchronized void setImageTooltipPreference(String player, boolean value) {
PlayerService.get(player).setShowImages(value);
}
public static synchronized void setEdgeColor(String player, String value) {
PlayerService.get(player).setEdgeColor(value);
}

public static synchronized boolean getImageTooltipPreference(String player) {
if (player == null) {
Expand All @@ -278,6 +281,13 @@ public static synchronized boolean getImageTooltipPreference(String player) {
return PlayerService.get(player).isShowImages();
}

public static synchronized String getEdgeColor(String player) {
if (player == null) {
return "#FFFFFF";
}
return PlayerService.get(player).getEdgeColor();
}

public static synchronized boolean isAdmin(String player) {
return PlayerService.get(player).getRoles().contains(PlayerRole.ADMIN);
}
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/net/deckserver/dwr/DeckserverRemote.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ public Map<String, Object> init() {
JolAdmin.resetView(playerName, currentGame);
}
boolean imagePreferences = JolAdmin.getImageTooltipPreference(playerName);
String edgeColor = JolAdmin.getEdgeColor(playerName);
Map<String, Object> update = UpdateFactory.getUpdate();
update.put("setPreferences", imagePreferences);
update.put("setEdgeColorPref", edgeColor);
return update;
}

Expand All @@ -152,6 +154,12 @@ public Map<String, Object> setUserPreferences(boolean imageTooltips) {
return UpdateFactory.getUpdate();
}

public Map<String, Object> setEdgeColor(String color) {
String playerName = getPlayer(request);
JolAdmin.setEdgeColor(playerName, color);
return UpdateFactory.getUpdate();
}

public Map<String, Object> navigate(String target) {
String playerName = getPlayer(request);
PlayerModel player = JolAdmin.getPlayerModel(playerName);
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/deckserver/dwr/bean/ProfileBean.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class ProfileBean {
private final String discordID;
private final String veknID;
private final String country;
private final String edgeColor;
private final boolean imageTooltipPreference;

public ProfileBean(PlayerModel model) {
Expand All @@ -22,6 +23,7 @@ public ProfileBean(PlayerModel model) {
this.discordID = playerInfo.getDiscordId();
this.veknID = playerInfo.getVeknId();
this.imageTooltipPreference = JolAdmin.getImageTooltipPreference(player);
this.edgeColor = JolAdmin.getEdgeColor(player);
this.country = playerInfo.getCountryCode();
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/deckserver/dwr/model/GameView.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.deckserver.game.enums.RegionType;
import net.deckserver.services.ChatService;
import net.deckserver.services.GameService;
import net.deckserver.services.PlayerService;
import net.deckserver.storage.json.game.ChatData;
import org.directwebremoting.WebContextFactory;
import org.slf4j.Logger;
Expand Down Expand Up @@ -136,6 +137,7 @@ public GameBean create() {
try {
request.setAttribute("game", game);
request.setAttribute("viewer", playerName);
request.setAttribute("edgeColor", PlayerService.get(playerName).getEdgeColor());
state = WebContextFactory.get().forwardToString("/WEB-INF/jsps/game/state.jsp");
} catch (Exception e) {
logger.error("Error retrieving state:", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class PlayerInfo {
private String countryCode;
private Set<PlayerRole> roles = new HashSet<>();
private boolean showImages = true;
private String edgeColor = "#FFFFFF";

public PlayerInfo(String name, String id, String email, String hash) {
this.name = name;
Expand Down
3 changes: 2 additions & 1 deletion src/main/webapp/WEB-INF/jsps/game/player.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
JolGame game = (JolGame) request.getAttribute("game");
String viewer = (String) request.getAttribute("viewer");
String player = request.getParameter("player");
String edgeColor = (String) request.getAttribute("edgeColor");
String playerIndex = request.getParameter("playerIndex");
boolean active = game.getActivePlayer().equals(player);
int pool = game.getPool(player);
Expand All @@ -28,7 +29,7 @@
<i class='bi-exclamation-triangle ms-2 pinged d-none'></i>
</span>
<c:if test="<%= edge %>">
<span class="badge text-bg-light border border-secondary fw-bold align-items-center d-flex gap-1">
<span class="badge border border-secondary fw-bold align-items-center d-flex gap-1" style="background: <%= edgeColor %>">
<i class="bi bi-chevron-left"></i>
Edge
<i class="bi bi-chevron-right"></i>
Expand Down
4 changes: 4 additions & 0 deletions src/main/webapp/WEB-INF/jsps/profile/preferences.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
<input class="form-check-input" type="checkbox" role="switch" id="imageTooltips" switch onclick="setImageTooltip()">
<label class="form-check-label" for="imageTooltips">Enable Image tooltips</label>
</div>
<div class="d-flex justify-content-start align-items-center">
<input type="color" id="edgecolorpicker" onchange="setEdgeColor()" style="width:8%;">
<label class="form-check-label m-1" for="edgecolorpicker">Choose Edge Color</label>
</div>
<%-- <div class="form-check form-switch">--%>
<%-- <input class="form-check-input" type="checkbox" role="switch" id="enableNotifications" switch onclick="enableNotifications()">--%>
<%-- <label class="form-check-label" for="enableNotifications">Enable notifications</label>--%>
Expand Down
14 changes: 13 additions & 1 deletion src/main/webapp/js/ds.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ let profile = {
email: "",
discordID: "",
updating: false,
imageTooltipPreference: true
imageTooltipPreference: true,
edgeColor: "#FFFFFF"
};
let subscribed = localStorage.getItem("notifications-subscribed") === "true";

Expand Down Expand Up @@ -48,6 +49,10 @@ function setPreferences(value) {
profile.imageTooltipPreference = value;
}

function setEdgeColorPref(value) {
profile.edgeColor = value;
}

function processData(a) {
$("#connectionMessage").addClass("d-none");
for (let b in a) {
Expand Down Expand Up @@ -538,6 +543,11 @@ function setImageTooltip() {
DS.setUserPreferences(profile.imageTooltipPreference, {callback: processData, errorHandler: errorhandler});
}

function setEdgeColor() {
profile.edgeColor = $("#edgecolorpicker").val();
DS.setEdgeColor(profile.edgeColor, {callback: processData, errorHandler: errorhandler});
}

function callbackProfile(data) {
if (profile.email !== data.email)
$('#profileEmail').val(data.email);
Expand All @@ -561,6 +571,8 @@ function callbackProfile(data) {
$("#imageTooltips").prop("checked", true);
}

$("#edgecolorpicker").val(data.edgeColor);

if (subscribed) {
$("#enableNotifications").prop("checked", true);
}
Expand Down