mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 16:44:48 -07:00
some zone view changes going on
This commit is contained in:
parent
aed30708de
commit
224a4969bd
25 changed files with 754 additions and 365 deletions
|
|
@ -5,62 +5,82 @@
|
|||
#include "zoneviewzone.h"
|
||||
#include "player.h"
|
||||
#include "client.h"
|
||||
#include "gamescene.h"
|
||||
|
||||
ZoneViewWidget::ZoneViewWidget(CardDatabase *_db, Player *_player, CardZone *_origZone, int numberCards, QGraphicsItem *parent)
|
||||
: QGraphicsWidget(parent, Qt::Tool | Qt::CustomizeWindowHint | Qt::WindowSystemMenuHint | Qt::WindowTitleHint/* | Qt::WindowCloseButtonHint*/), db(_db), player(_player)
|
||||
{
|
||||
setWindowTitle(QString("%1's %2").arg(player->getName()).arg(_origZone->getName()));
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
QFont font;
|
||||
font.setPixelSize(8);
|
||||
setFont(font);
|
||||
|
||||
qreal y = 10;
|
||||
QGraphicsLinearLayout *vbox = new QGraphicsLinearLayout(Qt::Vertical);
|
||||
setLayout(vbox);
|
||||
|
||||
sortCheckBox = new QCheckBox;
|
||||
QGraphicsProxyWidget *sortProxy = new QGraphicsProxyWidget;
|
||||
sortProxy->setWidget(sortCheckBox);
|
||||
vbox->addItem(sortProxy);
|
||||
|
||||
if (_origZone->getIsShufflable() && (numberCards == -1)) {
|
||||
shuffleCheckBox = new QCheckBox("shuffle when closing");
|
||||
shuffleCheckBox = new QCheckBox;
|
||||
shuffleCheckBox->setChecked(true);
|
||||
QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget(this);
|
||||
QGraphicsProxyWidget *shuffleProxy = new QGraphicsProxyWidget;
|
||||
shuffleProxy->setWidget(shuffleCheckBox);
|
||||
y += shuffleProxy->y() + shuffleProxy->size().height();
|
||||
vbox->addItem(shuffleProxy);
|
||||
} else
|
||||
shuffleCheckBox = 0;
|
||||
|
||||
|
||||
qreal left, top, right, bottom;
|
||||
getWindowFrameMargins(&left, &top, &right, &bottom);
|
||||
qreal h = scene()->sceneRect().height() - (top + bottom);
|
||||
|
||||
scrollBar = new QScrollBar(Qt::Vertical);
|
||||
/* scrollBar = new QScrollBar(Qt::Vertical);
|
||||
QGraphicsProxyWidget *scrollProxy = new QGraphicsProxyWidget(this);
|
||||
scrollProxy->setWidget(scrollBar);
|
||||
scrollProxy->setPos(138, y);
|
||||
scrollProxy->resize(scrollProxy->size().width(), h - y);
|
||||
|
||||
qreal w = 138 + scrollProxy->size().width();
|
||||
*/qreal w = 138;
|
||||
resize(w, h);
|
||||
setMinimumSize(w, h);
|
||||
setMaximumSize(w, h);
|
||||
|
||||
zone = new ZoneViewZone(player, _origZone, numberCards, this);
|
||||
zone->setPos(3, y);
|
||||
zone->setHeight((int) (h - y));
|
||||
if (!zone->initializeCards()) {
|
||||
connect(player->client, SIGNAL(zoneDumpReceived(int, QList<ServerZoneCard *>)), this, SLOT(zoneDumpReceived(int, QList<ServerZoneCard *>)));
|
||||
PendingCommand *dumpZoneCommand = player->client->dumpZone(player->getId(), _origZone->getName(), numberCards);
|
||||
cmdId = dumpZoneCommand->getMsgId();
|
||||
}
|
||||
connect(sortCheckBox, SIGNAL(stateChanged(int)), zone, SLOT(setSortingEnabled(int)));
|
||||
connect(zone, SIGNAL(contentsChanged()), this, SLOT(resizeToZoneContents()));
|
||||
zone->dumpObjectInfo();
|
||||
vbox->addItem(zone);
|
||||
zone->initializeCards();
|
||||
|
||||
QSettings settings;
|
||||
sortCheckBox->setChecked(settings.value("zoneview/sorting").toInt());
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
void ZoneViewWidget::zoneDumpReceived(int commandId, QList<ServerZoneCard *> cards)
|
||||
void ZoneViewWidget::retranslateUi()
|
||||
{
|
||||
if (commandId != cmdId)
|
||||
return;
|
||||
setWindowTitle(zone->getTranslatedName(false, CaseNominative));
|
||||
sortCheckBox->setText(tr("sort alphabetically"));
|
||||
if (shuffleCheckBox)
|
||||
shuffleCheckBox->setText(tr("shuffle when closing"));
|
||||
}
|
||||
|
||||
for (int i = 0; i < cards.size(); i++) {
|
||||
ServerZoneCard *temp = cards[i];
|
||||
|
||||
CardItem *card = new CardItem(db, temp->getName(), i, zone);
|
||||
zone->addCard(card, false, i);
|
||||
|
||||
delete temp;
|
||||
}
|
||||
zone->reorganizeCards();
|
||||
void ZoneViewWidget::resizeToZoneContents()
|
||||
{
|
||||
qDebug("+++++++ bla");
|
||||
int cardCount = zone->getCards().size();
|
||||
const QRectF &playersRect = static_cast<GameScene *>(scene())->getPlayersRect();
|
||||
int h = 0;
|
||||
if (cardCount * CARD_HEIGHT / 5 < playersRect.height() * 1.5)
|
||||
h = cardCount * CARD_HEIGHT / 5;
|
||||
else
|
||||
h = playersRect.height() * 1.5;
|
||||
qDebug(QString("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx resizing to %1").arg(h).toLatin1());
|
||||
resize(size().width(), h);
|
||||
emit sizeChanged();
|
||||
}
|
||||
|
||||
void ZoneViewWidget::closeEvent(QCloseEvent *event)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue