From 41eea77b0d9cb1d610512c6b1a037b4340a1507a Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Wed, 26 Oct 2011 17:50:00 +0000 Subject: [PATCH] Adding strength display to characters. --- .../lotro/game/state/EventSerializer.java | 3 +- .../gemp-lotr-web/src/main/webapp/game.html | 2 - .../src/main/webapp/js/gameUi.js | 85 ++++++++++--------- .../src/main/webapp/js/jCardGroup.js | 4 +- 4 files changed, 50 insertions(+), 44 deletions(-) diff --git a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/EventSerializer.java b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/EventSerializer.java index 6e096ee8f..40870f2b6 100644 --- a/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/EventSerializer.java +++ b/gemp-lotr/gemp-lotr-logic/src/main/java/com/gempukku/lotro/game/state/EventSerializer.java @@ -83,7 +83,8 @@ public class EventSerializer { if (charStr.length() > 0) charStr.delete(0, 1); - eventElem.setAttribute("charStrengths", charStr.toString()); + if (charStr.length() > 0) + eventElem.setAttribute("charStrengths", charStr.toString()); } return eventElem; diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html index 714d92019..546b2316a 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html @@ -30,13 +30,11 @@ } .cardStrength { - border-radius: 6px; text-align: center; vertical-align: middle; background-color: #ffffff; opacity: 0.7; color: #000000; - font-size: 200%; } .selectableCard > .borderOverlay { diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js index ed98a76d3..5d268261b 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js @@ -292,21 +292,21 @@ var GempLotrGameUI = Class.extend({ initializeDialogs: function() { this.smallDialog = $("
") .dialog({ - autoOpen: false, - closeOnEscape: false, - resizable: false, - width: 400, - height: 200 - }); + autoOpen: false, + closeOnEscape: false, + resizable: false, + width: 400, + height: 200 + }); this.cardActionDialog = $("
") .dialog({ - autoOpen: false, - closeOnEscape: false, - resizable: true, - width: 600, - height: 300 - }); + autoOpen: false, + closeOnEscape: false, + resizable: true, + width: 600, + height: 300 + }); var that = this; @@ -321,15 +321,15 @@ var GempLotrGameUI = Class.extend({ this.infoDialog = $("
") .dialog({ - autoOpen: false, - closeOnEscape: true, - resizable: true, - title: "Card information", - minHeight: 80, - minWidth: 200, - width: Math.max(600, width * 0.75), - height: Math.max(300, height * 0.75) - }); + autoOpen: false, + closeOnEscape: true, + resizable: true, + title: "Card information", + minHeight: 80, + minWidth: 200, + width: Math.max(600, width * 0.75), + height: Math.max(300, height * 0.75) + }); var swipeOptions = { threshold: 20, @@ -720,13 +720,13 @@ var GempLotrGameUI = Class.extend({ this.smallDialog .html(text + "
") .dialog("option", "buttons", - { - "OK": function() { - $(this).dialog("close"); - that.decisionFunction(id, $("#integerDecision").val()); - } - } - ); + { + "OK": function() { + $(this).dialog("close"); + that.decisionFunction(id, $("#integerDecision").val()); + } + } + ); $("#integerDecision").SpinnerControl({ type: 'range', typedata: { @@ -758,13 +758,13 @@ var GempLotrGameUI = Class.extend({ this.smallDialog .html(html) .dialog("option", "buttons", - { - "OK": function() { - $(this).dialog("close"); - that.decisionFunction(id, $("#multipleChoiceDecision").val()); - } - } - ); + { + "OK": function() { + $(this).dialog("close"); + that.decisionFunction(id, $("#multipleChoiceDecision").val()); + } + } + ); this.smallDialog.dialog("open"); }, @@ -781,10 +781,17 @@ var GempLotrGameUI = Class.extend({ var sizeListeners = new Array(); sizeListeners[0] = { sizeChanged: function(cardElem, width, height) { + var maxDimension = Math.max(width, height); + var borderWidth = Math.floor(maxDimension / 30); + + var size = Math.floor(maxDimension / 5); + var fontPerc = (size * 7) + "%"; + var borderRadius = Math.ceil(size / 5) + "px"; + if (cardElem.data("card").strength != null) - $(".cardStrength", cardElem).css({position: "absolute", left: width - 30 - 2 + "px", top: height - 30 - 2 + "px", width: 30, height: 30, display: ""}); + $(".cardStrength", cardElem).css({position: "absolute", "border-radius": borderRadius, "font-size": fontPerc, left: width - size - borderWidth - 2 + "px", top: height - size - borderWidth - 2 + "px", width: size, height: size, display: ""}); else - $(".cardStrength", cardElem).css({position: "absolute", left: width - 30 - 2 + "px", top: height - 30 - 2 + "px", width: 30, height: 30, display: "none"}); + $(".cardStrength", cardElem).css({position: "absolute", "border-radius": borderRadius, "font-size": fontPerc, left: width - size - borderWidth - 2 + "px", top: height - size - borderWidth - 2 + "px", width: size, height: size, display: "none"}); } }; @@ -1030,8 +1037,8 @@ var GempLotrGameUI = Class.extend({ $(div).find('LI.hover').removeClass('hover'); $(this).parent().addClass('hover'); }).mouseout(function() { - $(div).find('LI.hover').removeClass('hover'); - }); + $(div).find('LI.hover').removeClass('hover'); + }); var getRidOfContextMenu = function() { $(div).remove(); diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js index bfc447cef..cb0ed39bc 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/jCardGroup.js @@ -97,7 +97,7 @@ var AdvPathCardGroup = CardGroup.extend({ function(first, second) { return (first.data("card").siteNumber - second.data("card").siteNumber); } - ); + ); var cardCount = cardsToLayout.length; var totalHeight = 0; @@ -289,7 +289,7 @@ function layoutCardElem(cardElem, x, y, width, height, index) { var tokenOverlay = $(".tokenOverlay", cardElem); tokenOverlay.css({position: "absolute", left: 0 + "px", top: 0 + "px", width: width, height: height}); // Remove all existing tokens - (".token",tokenOverlay).remove(); + $(".token", tokenOverlay).remove(); $(".foilOverlay", cardElem).css({position: "absolute", left: 0 + "px", top: 0 + "px", width: width, height: height});