deck editor is tab, replay viewer is tab, deck editor shown by default, cache window geometry between sessions, 'open this deck in deck editor' open in game
This commit is contained in:
parent
3edecf98c3
commit
cc516823d7
13 changed files with 518 additions and 309 deletions
|
@ -24,7 +24,7 @@ bool MessageLogWidget::isFemale(Player *player) const
|
|||
|
||||
bool MessageLogWidget::userIsFemale() const
|
||||
{
|
||||
return (tabSupervisor && tabSupervisor->getUserInfo()->gender() & ServerInfo_User::Female);
|
||||
return (tabSupervisor && tabSupervisor->getUserInfo() && (tabSupervisor->getUserInfo()->gender() & ServerInfo_User::Female));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logGameJoined(int gameId)
|
||||
|
|
|
@ -205,6 +205,9 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
|||
aAlwaysRevealTopCard = new QAction(this);
|
||||
aAlwaysRevealTopCard->setCheckable(true);
|
||||
connect(aAlwaysRevealTopCard, SIGNAL(triggered()), this, SLOT(actAlwaysRevealTopCard()));
|
||||
aOpenDeckInDeckEditor = new QAction(this);
|
||||
aOpenDeckInDeckEditor->setEnabled(false);
|
||||
connect(aOpenDeckInDeckEditor, SIGNAL(triggered()), this, SLOT(actOpenDeckInDeckEditor()));
|
||||
}
|
||||
|
||||
aViewGraveyard = new QAction(this);
|
||||
|
@ -262,6 +265,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
|||
playerLists.append(mRevealLibrary = libraryMenu->addMenu(QString()));
|
||||
playerLists.append(mRevealTopCard = libraryMenu->addMenu(QString()));
|
||||
libraryMenu->addAction(aAlwaysRevealTopCard);
|
||||
libraryMenu->addAction(aOpenDeckInDeckEditor);
|
||||
libraryMenu->addSeparator();
|
||||
libraryMenu->addAction(aMoveTopCardsToGrave);
|
||||
libraryMenu->addAction(aMoveTopCardsToExile);
|
||||
|
@ -595,6 +599,7 @@ void Player::retranslateUi()
|
|||
mRevealLibrary->setTitle(tr("Reveal &library to"));
|
||||
mRevealTopCard->setTitle(tr("Reveal t&op card to"));
|
||||
aAlwaysRevealTopCard->setText(tr("&Always reveal top card"));
|
||||
aOpenDeckInDeckEditor->setText(tr("O&pen deck in deck editor"));
|
||||
aViewSideboard->setText(tr("&View sideboard"));
|
||||
aDrawCard->setText(tr("&Draw card"));
|
||||
aDrawCards->setText(tr("D&raw cards..."));
|
||||
|
@ -744,6 +749,7 @@ void Player::initSayMenu()
|
|||
void Player::setDeck(DeckList *_deck)
|
||||
{
|
||||
deck = _deck;
|
||||
aOpenDeckInDeckEditor->setEnabled(deck);
|
||||
|
||||
createPredefinedTokenMenu->clear();
|
||||
predefinedTokens.clear();
|
||||
|
@ -783,6 +789,11 @@ void Player::actAlwaysRevealTopCard()
|
|||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actOpenDeckInDeckEditor()
|
||||
{
|
||||
emit openDeckEditor(new DeckList(deck));
|
||||
}
|
||||
|
||||
void Player::actViewGraveyard()
|
||||
{
|
||||
static_cast<GameScene *>(scene())->toggleZoneView(this, "grave", -1);
|
||||
|
|
|
@ -77,6 +77,7 @@ public:
|
|||
class Player : public QObject, public QGraphicsItem {
|
||||
Q_OBJECT
|
||||
signals:
|
||||
void openDeckEditor(DeckList *deck);
|
||||
void newCardAdded(AbstractCardItem *card);
|
||||
// Log events
|
||||
void logSay(Player *player, QString message);
|
||||
|
@ -134,6 +135,7 @@ private slots:
|
|||
void updateBoundingRect();
|
||||
void rearrangeZones();
|
||||
|
||||
void actOpenDeckInDeckEditor();
|
||||
void actCreatePredefinedToken();
|
||||
void cardMenuAction();
|
||||
void actCardCounterTrigger();
|
||||
|
@ -161,7 +163,7 @@ private:
|
|||
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg,
|
||||
*aMoveGraveToTopLibrary, *aMoveGraveToBottomLibrary, *aMoveGraveToHand, *aMoveGraveToRfg,
|
||||
*aMoveRfgToTopLibrary, *aMoveRfgToBottomLibrary, *aMoveRfgToHand, *aMoveRfgToGrave,
|
||||
*aViewLibrary, *aViewTopCards, *aAlwaysRevealTopCard, *aMoveTopCardsToGrave, *aMoveTopCardsToExile, *aMoveTopCardToBottom,
|
||||
*aViewLibrary, *aViewTopCards, *aAlwaysRevealTopCard, *aOpenDeckInDeckEditor, *aMoveTopCardsToGrave, *aMoveTopCardsToExile, *aMoveTopCardToBottom,
|
||||
*aViewGraveyard, *aViewRfg, *aViewSideboard,
|
||||
*aDrawCard, *aDrawCards, *aUndoDraw, *aMulligan, *aShuffle,
|
||||
*aUntapAll, *aRollDie, *aCreateToken, *aCreateAnotherToken,
|
||||
|
|
|
@ -19,6 +19,7 @@ SettingsCache::SettingsCache()
|
|||
playerBgPath = settings->value("zonebg/playerarea").toString();
|
||||
cardBackPicturePath = settings->value("paths/cardbackpicture").toString();
|
||||
|
||||
mainWindowGeometry = settings->value("interface/main_window_geometry").toByteArray();
|
||||
picDownload = settings->value("personal/picturedownload", true).toBool();
|
||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||
cardInfoMinimized = settings->value("interface/cardinfominimized", 0).toInt();
|
||||
|
@ -211,3 +212,9 @@ void SettingsCache::setIgnoreUnregisteredUsers(bool _ignoreUnregisteredUsers)
|
|||
settings->setValue("chat/ignore_unregistered", ignoreUnregisteredUsers);
|
||||
emit ignoreUnregisteredUsersChanged();
|
||||
}
|
||||
|
||||
void SettingsCache::setMainWindowGeometry(const QByteArray &_mainWindowGeometry)
|
||||
{
|
||||
mainWindowGeometry = _mainWindowGeometry;
|
||||
settings->setValue("interface/main_window_geometry", mainWindowGeometry);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ signals:
|
|||
private:
|
||||
QSettings *settings;
|
||||
|
||||
QByteArray mainWindowGeometry;
|
||||
QString customTranslationFile, lang;
|
||||
QString deckPath, replaysPath, picsPath, cardDatabasePath;
|
||||
QString handBgPath, stackBgPath, tableBgPath, playerBgPath, cardBackPicturePath;
|
||||
|
@ -46,6 +47,7 @@ private:
|
|||
bool ignoreUnregisteredUsers;
|
||||
public:
|
||||
SettingsCache();
|
||||
const QByteArray &getMainWindowGeometry() const { return mainWindowGeometry; }
|
||||
QString getCustomTranslationFile() const { return customTranslationFile; }
|
||||
QString getLang() const { return lang; }
|
||||
QString getDeckPath() const { return deckPath; }
|
||||
|
@ -73,6 +75,7 @@ public:
|
|||
bool getPriceTagFeature() const { return priceTagFeature; }
|
||||
bool getIgnoreUnregisteredUsers() const { return ignoreUnregisteredUsers; }
|
||||
public slots:
|
||||
void setMainWindowGeometry(const QByteArray &_mainWindowGeometry);
|
||||
void setCustomTranslationFile(const QString &_customTranslationFile);
|
||||
void setLang(const QString &_lang);
|
||||
void setDeckPath(const QString &_deckPath);
|
||||
|
|
|
@ -181,7 +181,7 @@ TabDeckEditor::TabDeckEditor(TabSupervisor *_tabSupervisor, QWidget *parent)
|
|||
connect(aPrintDeck, SIGNAL(triggered()), this, SLOT(actPrintDeck()));
|
||||
aClose = new QAction(tr("&Close"), this);
|
||||
aClose->setShortcut(tr("Ctrl+Q"));
|
||||
connect(aClose, SIGNAL(triggered()), this, SLOT(close()));
|
||||
connect(aClose, SIGNAL(triggered()), this, SLOT(closeRequest()));
|
||||
|
||||
aEditSets = new QAction(tr("&Edit sets..."), this);
|
||||
connect(aEditSets, SIGNAL(triggered()), this, SLOT(actEditSets()));
|
||||
|
@ -289,7 +289,6 @@ void TabDeckEditor::updateName(const QString &name)
|
|||
{
|
||||
deckModel->getDeckList()->setName(name);
|
||||
setWindowModified(true);
|
||||
emit tabTextChanged(this, getTabText());
|
||||
}
|
||||
|
||||
void TabDeckEditor::updateComments()
|
||||
|
@ -568,3 +567,9 @@ void TabDeckEditor::setDeck(DeckList *_deck, const QString &_lastFileName, DeckL
|
|||
deckView->expandAll();
|
||||
setWindowModified(false);
|
||||
}
|
||||
|
||||
void TabDeckEditor::setWindowModified(bool _windowModified)
|
||||
{
|
||||
Tab::setWindowModified(_windowModified);
|
||||
emit tabTextChanged(this, getTabText());
|
||||
}
|
||||
|
|
|
@ -90,8 +90,10 @@ public:
|
|||
~TabDeckEditor();
|
||||
void retranslateUi();
|
||||
QString getTabText() const;
|
||||
void closeRequest();
|
||||
void setDeck(DeckList *_deck, const QString &_lastFileName = QString(), DeckList::FileFormat _lastFileFormat = DeckList::CockatriceFormat);
|
||||
void setWindowModified(bool _windowModified);
|
||||
public slots:
|
||||
void closeRequest();
|
||||
signals:
|
||||
void deckEditorClosing(TabDeckEditor *tab);
|
||||
};
|
||||
|
|
|
@ -734,6 +734,7 @@ Player *TabGame::addPlayer(int playerId, const ServerInfo_User &info)
|
|||
{
|
||||
bool local = ((clients.size() > 1) || (playerId == localPlayerId));
|
||||
Player *newPlayer = new Player(info, playerId, local, this);
|
||||
connect(newPlayer, SIGNAL(openDeckEditor(DeckList *)), this, SIGNAL(openDeckEditor(DeckList *)));
|
||||
scene->addPlayer(newPlayer);
|
||||
|
||||
connect(newPlayer, SIGNAL(newCardAdded(AbstractCardItem *)), this, SLOT(newCardAdded(AbstractCardItem *)));
|
||||
|
|
|
@ -171,6 +171,7 @@ signals:
|
|||
void containerProcessingStarted(const GameEventContext &context);
|
||||
void containerProcessingDone();
|
||||
void openMessageDialog(const QString &userName, bool focus);
|
||||
void openDeckEditor(DeckList *deck);
|
||||
private slots:
|
||||
void replayNextEvent();
|
||||
void replayFinished();
|
||||
|
|
|
@ -208,12 +208,14 @@ void TabSupervisor::stop()
|
|||
tabDeckStorage->deleteLater();
|
||||
if (tabReplays)
|
||||
tabReplays->deleteLater();
|
||||
if (tabAdmin)
|
||||
tabAdmin->deleteLater();
|
||||
}
|
||||
tabUserLists = 0;
|
||||
tabServer = 0;
|
||||
tabDeckStorage = 0;
|
||||
tabReplays = 0;
|
||||
clear();
|
||||
tabAdmin = 0;
|
||||
|
||||
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
||||
while (roomIterator.hasNext())
|
||||
|
@ -235,10 +237,6 @@ void TabSupervisor::stop()
|
|||
messageIterator.next().value()->deleteLater();
|
||||
messageTabs.clear();
|
||||
|
||||
QListIterator<TabDeckEditor *> deckEditorIterator(deckEditorTabs);
|
||||
while (deckEditorIterator.hasNext())
|
||||
deckEditorIterator.next()->deleteLater();
|
||||
|
||||
delete userInfo;
|
||||
userInfo = 0;
|
||||
}
|
||||
|
@ -250,7 +248,7 @@ void TabSupervisor::updatePingTime(int value, int max)
|
|||
if (tabServer->getContentsChanged())
|
||||
return;
|
||||
|
||||
setTabIcon(0, QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
|
||||
setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
|
||||
}
|
||||
|
||||
void TabSupervisor::closeButtonPressed()
|
||||
|
@ -281,6 +279,7 @@ void TabSupervisor::gameJoined(const Event_GameJoined &event)
|
|||
TabGame *tab = new TabGame(this, QList<AbstractClient *>() << client, event, roomGameTypes);
|
||||
connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *)));
|
||||
connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
||||
connect(tab, SIGNAL(openDeckEditor(DeckList *)), this, SLOT(addDeckEditorTab(DeckList *)));
|
||||
int tabIndex = myAddTab(tab);
|
||||
addCloseButtonToTab(tab, tabIndex);
|
||||
gameTabs.insert(event.game_info().game_id(), tab);
|
||||
|
@ -291,6 +290,7 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
|
|||
{
|
||||
TabGame *tab = new TabGame(this, localClients, event, QMap<int, QString>());
|
||||
connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *)));
|
||||
connect(tab, SIGNAL(openDeckEditor(DeckList *)), this, SLOT(addDeckEditorTab(DeckList *)));
|
||||
int tabIndex = myAddTab(tab);
|
||||
addCloseButtonToTab(tab, tabIndex);
|
||||
gameTabs.insert(event.game_info().game_id(), tab);
|
||||
|
@ -387,6 +387,8 @@ void TabSupervisor::talkLeft(TabMessage *tab)
|
|||
TabDeckEditor *TabSupervisor::addDeckEditorTab(DeckList *deckToOpen)
|
||||
{
|
||||
TabDeckEditor *tab = new TabDeckEditor(this);
|
||||
if (deckToOpen)
|
||||
tab->setDeck(deckToOpen);
|
||||
connect(tab, SIGNAL(deckEditorClosing(TabDeckEditor *)), this, SLOT(deckEditorClosed(TabDeckEditor *)));
|
||||
int tabIndex = myAddTab(tab);
|
||||
addCloseButtonToTab(tab, tabIndex);
|
||||
|
|
|
@ -76,6 +76,7 @@ signals:
|
|||
void adminLockChanged(bool lock);
|
||||
public slots:
|
||||
TabDeckEditor *addDeckEditorTab(DeckList *deckToOpen);
|
||||
void openReplay(GameReplay *replay);
|
||||
private slots:
|
||||
void closeButtonPressed();
|
||||
void updateCurrent(int index);
|
||||
|
@ -86,7 +87,6 @@ private slots:
|
|||
void addRoomTab(const ServerInfo_Room &info, bool setCurrent);
|
||||
void roomLeft(TabRoom *tab);
|
||||
TabMessage *addMessageTab(const QString &userName, bool focus);
|
||||
void openReplay(GameReplay *replay);
|
||||
void replayLeft(TabGame *tab);
|
||||
void processUserLeft(const QString &userName);
|
||||
void processUserJoined(const ServerInfo_User &userInfo);
|
||||
|
|
|
@ -56,7 +56,7 @@ void MainWindow::updateTabMenu(const QList<QMenu *> &newMenuList)
|
|||
menuBar()->removeAction(tabMenus[i]->menuAction());
|
||||
tabMenus = newMenuList;
|
||||
for (int i = 0; i < tabMenus.size(); ++i)
|
||||
menuBar()->insertMenu(tabMenus[i]->menuAction(), tabMenus[i]);
|
||||
menuBar()->insertMenu(helpMenu->menuAction(), tabMenus[i]);
|
||||
}
|
||||
|
||||
void MainWindow::processConnectionClosedEvent(const Event_ConnectionClosed &event)
|
||||
|
@ -175,8 +175,7 @@ void MainWindow::actWatchReplay()
|
|||
GameReplay *replay = new GameReplay;
|
||||
replay->ParseFromArray(buf.data(), buf.size());
|
||||
|
||||
TabGame *replayWatcher = new TabGame(0, replay);
|
||||
replayWatcher->show();
|
||||
tabSupervisor->openReplay(replay);
|
||||
}
|
||||
|
||||
void MainWindow::localGameEnded()
|
||||
|
@ -386,6 +385,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
retranslateUi();
|
||||
|
||||
resize(900, 700);
|
||||
restoreGeometry(settingsCache->getMainWindowGeometry());
|
||||
aFullScreen->setChecked(windowState() & Qt::WindowFullScreen);
|
||||
}
|
||||
|
||||
MainWindow::~MainWindow()
|
||||
|
@ -403,6 +404,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
|
|||
}
|
||||
}
|
||||
event->accept();
|
||||
settingsCache->setMainWindowGeometry(saveGeometry());
|
||||
delete tabSupervisor;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue