From 01597629595eec6aa788d44d01c94b40ebcc428b Mon Sep 17 00:00:00 2001 From: QuiteQuiet Date: Wed, 2 Nov 2016 21:06:10 +0100 Subject: [PATCH] Update battle log when ignoring something (#784) --- js/battle.js | 18 +++++++++++++----- js/client-battle.js | 26 ++++++++++++++++++++++++++ style/battle.css | 9 +++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/js/battle.js b/js/battle.js index 801b4e6b8..e9d2757dc 100644 --- a/js/battle.js +++ b/js/battle.js @@ -524,18 +524,21 @@ var Pokemon = (function () { this.baseAbility = ability; } }; + Pokemon.prototype.htmlName = function () { + return '' + Tools.escapeHTML(this.name) + ''; + }; Pokemon.prototype.getName = function (shortName) { if (this.side.n === 0) { - return Tools.escapeHTML(this.name); + return this.htmlName(); } else { - return (shortName ? "Opposing " : "The opposing ") + (this.side.battle.ignoreOpponent || this.side.battle.ignoreNicks ? this.species : Tools.escapeHTML(this.name)); + return (shortName ? "Opposing " : "The opposing ") + this.htmlName(); } }; Pokemon.prototype.getLowerName = function (shortName) { if (this.side.n === 0) { - return Tools.escapeHTML(this.name); + return this.htmlName(); } else { - return (shortName ? "opposing " : "the opposing ") + (this.side.battle.ignoreOpponent || this.side.battle.ignoreNicks ? this.species : Tools.escapeHTML(this.name)); + return (shortName ? "opposing " : "the opposing ") + this.htmlName(); } }; Pokemon.prototype.getTitle = function () { @@ -553,7 +556,7 @@ var Pokemon = (function () { if (plaintext) { name += ' (' + this.species + ')'; } else { - name += ' (' + this.species + ')'; + name = '' + name + ' (' + this.species + ')' + ''; } } if (plaintext) { @@ -2474,6 +2477,11 @@ var Battle = (function () { if (this.mySide) this.mySide.reset(); if (this.yourSide) this.yourSide.reset(); + if (this.ignoreNicks) { + var $log = $('.battle-log .inner'); + if ($log.length) $log.addClass('hidenicks'); + } + // activity queue state this.animationDelay = 0; this.multiHitMove = null; diff --git a/js/client-battle.js b/js/client-battle.js index 68343dd86..f653b24a0 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -1120,6 +1120,13 @@ toggleIgnoreSpects: function (e) { this.battle.ignoreSpects = !!e.currentTarget.checked; this.battle.add('Spectators ' + (this.battle.ignoreSpects ? '' : 'no longer ') + 'ignored.'); + var $messages = $('.battle-log').find('.chat').not('small:contains(\u2605)'); + if (!$messages.length) return; + if (this.battle.ignoreSpects) { + $messages.hide(); + } else { + $messages.show(); + } }, toggleIgnoreNicks: function (e) { this.battle.ignoreNicks = !!e.currentTarget.checked; @@ -1127,13 +1134,32 @@ this.battle.add('Nicknames ' + (this.battle.ignoreNicks ? '' : 'no longer ') + 'ignored.'); this.toggleNicknames(this.battle.mySide); this.toggleNicknames(this.battle.yourSide); + + var $log = $('.battle-log .inner'); + if (!$log.length) return; + if (this.battle.ignoreNicks) { + $log.addClass('hidenicks'); + } else { + $log.removeClass('hidenicks'); + } }, toggleIgnoreOpponent: function (e) { this.battle.ignoreOpponent = !!e.currentTarget.checked; this.battle.add('Opponent ' + (this.battle.ignoreOpponent ? '' : 'no longer ') + 'ignored.'); + var $log = $('.battle-log .inner'); + var $messages = $log.find('.chatmessage-' + this.battle.yourSide.id); + if (!$messages.length) return; + if (this.battle.ignoreOpponent) { + $messages.hide(); + $log.addClass('hidenicks'); + } else { + $messages.show(); + $log.removeClass('hidenicks'); + } }, toggleNicknames: function (side) { for (var i = 0; i < side.active.length; i++) { + if (!side.active[i]) continue; side.active[i].statbarElem.html(side.getStatbarHTML(side.active[i], true)); side.updateStatbar(side.active[i], true, true); } diff --git a/style/battle.css b/style/battle.css index b24804e4d..539017fea 100644 --- a/style/battle.css +++ b/style/battle.css @@ -906,3 +906,12 @@ button.subtle { button.subtle:hover { text-decoration: underline; } +.hidenicks span.battle-nickname, +.hidenicks span.battle-nickname-foe { + font-size: 0; +} +.hidenicks span.battle-nickname::before, +.hidenicks span.battle-nickname-foe::before{ + content: attr(title); + font-size: 9pt; +}