From 66cade4cb228da6ca30d270d68ef166fd938678f Mon Sep 17 00:00:00 2001 From: Tissevert Date: Tue, 14 Jan 2020 11:19:03 +0100 Subject: [PATCH] Keep a line in games list for negative answers to let the user know about them and dismiss the news when they read it --- js/GUI/Screen/Hall.js | 11 +++++++++-- js/GUI/Screen/Hall/Games.js | 12 ++++++++++-- js/Translations.js | 6 ++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/js/GUI/Screen/Hall.js b/js/GUI/Screen/Hall.js index 0c9df38..319505a 100644 --- a/js/GUI/Screen/Hall.js +++ b/js/GUI/Screen/Hall.js @@ -31,8 +31,15 @@ function init() { GamesGUI.refresh(); }); Messaging.addEventListener(["Relay", "Answer"], function(o) { - Games.entries.remove(o.from); - GamesGUI.refresh(); + var gameEntry = Games.entries.get(o.from); + if(gameEntry != undefined) { + if(!o.message.accept) { + gameEntry.answer = false; + } else { + Games.entries.remove(o.from); + } + GamesGUI.refresh(); + } }); Messaging.addEventListener(["Game"], function(o) { GamesGUI.refresh(); diff --git a/js/GUI/Screen/Hall/Games.js b/js/GUI/Screen/Hall/Games.js index e9def1b..85b6192 100644 --- a/js/GUI/Screen/Hall/Games.js +++ b/js/GUI/Screen/Hall/Games.js @@ -23,8 +23,16 @@ function showGame(game) { } function gameProposal(game) { - var properties = { - textContent: I18n.get('proposedGame')(game.value.yourTurn, game.value.vs.name), + var properties = {}; + if(game.value.answer != undefined) { + properties.textContent = I18n.get('refusedGame')(game.value.vs.name); + properties.class = 'clickable'; + properties.onClick = function() {Games.entries.remove(game.key); refresh();}; + } else { + properties.textContent = I18n.get('proposedGame')( + game.value.yourTurn, + game.value.vs.name + ); }; if(game.value.yourTurn) { properties.onClick = answerDialog(game.value.vs.id); diff --git a/js/Translations.js b/js/Translations.js index 3bc9bea..c2b4a7d 100644 --- a/js/Translations.js +++ b/js/Translations.js @@ -46,6 +46,9 @@ return { } }, questionAccept: "Do you want to start the game ?", + refusedGame: function(name) { + return name + " refused your invitation"; + }, startGameWith: "Start a game with", theyScored: function(name) { return name + " scored"; @@ -101,6 +104,9 @@ return { } }, questionAccept: "Voulez-vous commencer la partie ?", + refusedGame: function(name) { + return name + " a décliné votre invitation"; + }, startGameWith: "Commencer une partie avec", theyScored: function(name) { return name + " a marqué";