From 60550389d5fe3b2cf462ae752ba9c6d100f43e0f Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Thu, 22 Sep 2011 23:17:27 +0000 Subject: [PATCH] "Fixing" Athelas and other possesions - basically any card that had multiple possible actions to use, now a context menu pops up with possible actions. --- .../main/webapp/css/jquery.contextMenu.css | 48 ++++++++++++++ .../gemp-lotr-web/src/main/webapp/game.html | 1 + .../src/main/webapp/includes/changeLog.html | 3 + .../src/main/webapp/js/gameUi.js | 64 +++++++++++++++++-- 4 files changed, 111 insertions(+), 5 deletions(-) create mode 100644 gemp-lotr/gemp-lotr-web/src/main/webapp/css/jquery.contextMenu.css diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/css/jquery.contextMenu.css b/gemp-lotr/gemp-lotr-web/src/main/webapp/css/jquery.contextMenu.css new file mode 100644 index 000000000..0156724cb --- /dev/null +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/css/jquery.contextMenu.css @@ -0,0 +1,48 @@ +/* Generic context menu styles */ +.contextMenu { + position: absolute; + width: 200px; + z-index: 99999; + border: solid 1px #CCC; + background: #EEE; + padding: 0px; + margin: 0px; + display: none; +} + +.contextMenu LI { + list-style: none; + padding: 0px; + margin: 0px; + overflow: hidden; +} + +.contextMenu A { + color: #333; + text-decoration: none; + display: block; + line-height: 20px; + height: 20px; + background-position: 6px center; + background-repeat: no-repeat; + outline: none; + padding: 1px 5px; +} + +.contextMenu LI.hover A { + color: #FFF; + background-color: #3399FF; +} + +.contextMenu LI.disabled A { + color: #AAA; + cursor: default; +} + +.contextMenu LI.hover.disabled A { + background-color: transparent; +} + +.contextMenu LI.separator { + border-top: solid 1px #CCC; +} \ No newline at end of file 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 d26008fcb..c3a78864f 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/game.html @@ -116,6 +116,7 @@ } + diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html index 691977308..db224ec6f 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/includes/changeLog.html @@ -3,6 +3,9 @@ - Changed the main page after logging in to give access to additional documents. - Changed the play event animation so that player might actually recognize the card. - The animations are no longer shown to the player who initiated the effect, he should know what he played. +- Fixed Athelas and some other possessions, that could not be used during Fellowship phase if a valid transfer target +could be spotted. The problem was, that in that case there are 2 (or more) possible actions to do with 1 card. Now +a small context menu will show up in that case and user will be able to choose, which action to perform. 21 Sept. 2011 - Increased the time per game per player to 40 minutes, as 30 seems not enough. 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 00456f8ef..c61b956cd 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 @@ -241,7 +241,7 @@ var GempLotrGameUI = Class.extend({ if (event.shiftKey) { this.displayCardInfo(selectedCardElem.data("card")); } else if (selectedCardElem.hasClass("selectableCard")) - this.selectionFunction(selectedCardElem.data("card").cardId); + this.selectionFunction(selectedCardElem.data("card").cardId, event); } } } @@ -1182,12 +1182,12 @@ var GempLotrGameUI = Class.extend({ actions.push({ actionId: actionId, actionText: actionText }); } - that.selectionFunction = function(cardId) { + that.selectionFunction = function(cardId, event) { var cardIdElem = $(".card:cardId(" + cardId + ")"); var actions = cardIdElem.data("action"); - if (actions.length == 1) { - var action = actions[0]; - selectedCardIds.push(action.actionId); + + var selectActionFunction = function(actionId) { + selectedCardIds.push(actionId); if (that.settingsAutoAccept) { finishChoice(); } else { @@ -1195,6 +1195,13 @@ var GempLotrGameUI = Class.extend({ $(".card:cardId(" + cardId + ")").addClass("selectedCard"); processButtons(); } + }; + + if (actions.length == 1) { + var action = actions[0]; + selectActionFunction(action.actionId); + } else { + that.createActionChoiceContextMenu(actions, event, selectActionFunction); } }; @@ -1205,6 +1212,53 @@ var GempLotrGameUI = Class.extend({ processButtons(); }, + createActionChoiceContextMenu: function(actions, event, selectActionFunction) { + // Remove context menus that may be showing + $(".contextMenu").remove(); + + var div = $(""); + for (var i = 0; i < actions.length; i++) { + var action = actions[i]; + var text = action.actionText; + div.append("
  • " + text + "
  • "); + } + + $("#main").append(div); + + var x = event.pageX; + var y = event.pageY; + $(div).css({left: x, top: y}).fadeIn(150); + + $(div).find('A').mouseover(function() { + $(div).find('LI.hover').removeClass('hover'); + $(this).parent().addClass('hover'); + }).mouseout(function() { + $(div).find('LI.hover').removeClass('hover'); + }); + + var getRidOfContextMenu = function() { + $(div).remove(); + $(document).unbind("click", getRidOfContextMenu); + return false; + }; + + // When items are selected + $(div).find('A').unbind('click'); + $(div).find('LI:not(.disabled) A').click(function() { + $(document).unbind('click', getRidOfContextMenu); + $(".contextMenu").remove(); + + var actionId = $(this).attr('href').substr(1); + selectActionFunction(actionId); + return false; + }); + + // Hide bindings + setTimeout(function() { // Delay for Mozilla + $(document).click(getRidOfContextMenu); + }, 0); + }, + // Choosing one action to resolve, for example required triggered actions actionChoiceDecision: function (decision) { var id = decision.getAttribute("id");