mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
Some checks are pending
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 15 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Docker Image / amd64 & arm64 (push) Waiting to run
* [Game][Player] Pull out graphics_items out of player_logic Took 25 seconds Took 9 minutes * [Game] Move graphics files into game_graphics Took 1 minute Took 2 minutes Took 23 seconds Took 1 minute Took 2 seconds * Include. Took 4 minutes Took 3 minutes Took 4 minutes Took 1 minute Took 3 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
#include "tabbed_deck_view_container.h"
|
|
|
|
#include "../../interface/widgets/tabs/tab_game.h"
|
|
#include "deck_view.h"
|
|
|
|
TabbedDeckViewContainer::TabbedDeckViewContainer(int _playerId, TabGame *parent)
|
|
: QTabWidget(nullptr), playerId(_playerId), parentGame(parent)
|
|
{
|
|
setTabsClosable(true);
|
|
connect(this, &QTabWidget::tabCloseRequested, this, &TabbedDeckViewContainer::closeTab);
|
|
|
|
playerDeckView = new DeckViewContainer(playerId, parentGame);
|
|
int playerTabIndex = addTab(playerDeckView, "Your Deck");
|
|
tabBar()->setTabButton(playerTabIndex, QTabBar::RightSide, nullptr);
|
|
updateTabBarVisibility();
|
|
}
|
|
|
|
void TabbedDeckViewContainer::addOpponentDeckView(const DeckList &opponentDeck, int opponentId, QString opponentName)
|
|
{
|
|
if (opponentDeckViews.contains(opponentId)) {
|
|
opponentDeckViews[opponentId]->setDeck(opponentDeck);
|
|
} else {
|
|
auto *opponentDeckView = new DeckView(this);
|
|
connect(opponentDeckView, &DeckView::newCardAdded, playerDeckView, &DeckViewContainer::newCardAdded);
|
|
|
|
opponentDeckView->setDeck(opponentDeck);
|
|
|
|
addTab(opponentDeckView, QString("%1's Deck").arg(opponentName));
|
|
|
|
opponentDeckViews.insert(opponentId, opponentDeckView);
|
|
}
|
|
updateTabBarVisibility();
|
|
}
|
|
|
|
void TabbedDeckViewContainer::closeTab(int index)
|
|
{
|
|
QWidget *widgetToClose = widget(index);
|
|
|
|
// Prevent removing the player tab
|
|
if (widgetToClose == playerDeckView) {
|
|
return;
|
|
}
|
|
|
|
// Remove it from map if it's an opponent
|
|
auto it = opponentDeckViews.begin();
|
|
while (it != opponentDeckViews.end()) {
|
|
if (it.value() == widgetToClose) {
|
|
it = opponentDeckViews.erase(it);
|
|
} else {
|
|
++it;
|
|
}
|
|
}
|
|
|
|
removeTab(index);
|
|
widgetToClose->deleteLater();
|
|
updateTabBarVisibility();
|
|
}
|
|
|
|
void TabbedDeckViewContainer::updateTabBarVisibility()
|
|
{
|
|
if (tabBar()->count() <= 1) {
|
|
tabBar()->hide();
|
|
} else {
|
|
tabBar()->show();
|
|
}
|
|
}
|