From ef86f763e5e1a0bdef960c890f7e2984b63e506d Mon Sep 17 00:00:00 2001 From: asgdf Date: Mon, 24 Apr 2017 03:30:16 +0200 Subject: [PATCH] Add option to open new battle rooms on the right (#900) --- js/client-battle.js | 10 +++++++++- js/client.js | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/js/client-battle.js b/js/client-battle.js index afb94449f..0c02793b7 100644 --- a/js/client-battle.js +++ b/js/client-battle.js @@ -9,6 +9,8 @@ initialize: function (data) { this.me = {}; + this.isSideRoom = Tools.prefs('rightpanelbattles'); + this.$el.addClass('ps-room-opaque').html('
Battle is here
Connecting...
'); this.$battle = this.$el.find('.battle'); @@ -1237,18 +1239,21 @@ var BattleOptionsPopup = this.BattleOptionsPopup = Popup.extend({ initialize: function (data) { this.battle = data.battle; + var rightPanelBattlesPossible = (MainMenuRoom.prototype.bestWidth + BattleRoom.prototype.minWidth < $(window).width()); var buf = '

In this battle

'; buf += '

'; buf += '

'; buf += '

All battles

'; buf += '

'; + if (rightPanelBattlesPossible) buf += '

'; buf += '

'; this.$el.html(buf); }, events: { 'change input[name=ignorespects]': 'toggleIgnoreSpects', 'change input[name=ignorenicks]': 'toggleIgnoreNicks', - 'change input[name=ignoreopp]': 'toggleIgnoreOpponent' + 'change input[name=ignoreopp]': 'toggleIgnoreOpponent', + 'change input[name=rightpanelbattles]': 'toggleRightPanelBattles' }, toggleIgnoreSpects: function (e) { this.battle.ignoreSpects = !!e.currentTarget.checked; @@ -1297,6 +1302,9 @@ side.updateStatbar(side.active[i], true, true); } side.updateSidebar(); + }, + toggleRightPanelBattles: function (e) { + Tools.prefs('rightpanelbattles', !!e.currentTarget.checked); } }); diff --git a/js/client.js b/js/client.js index 60dbbd3a1..df0b00646 100644 --- a/js/client.js +++ b/js/client.js @@ -1325,8 +1325,13 @@ if (this.curSideRoom === oldRoom) this.curSideRoom = room; if (this.sideRoom === oldRoom) this.sideRoom = room; } - if (type === BattleRoom) this.roomList.push(room); - if (type === ChatRoom || type === BattlesRoom) this.sideRoomList.push(room); + if (['', 'teambuilder', 'ladder', 'rooms'].indexOf(room.id) < 0) { + if (room.isSideRoom) { + this.sideRoomList.push(room); + } else { + this.roomList.push(room); + } + } return room; }, focusRoom: function (id) {