void CCardLabel::mouseMoveEvent(QMouseEvent *ev)
{
    if (mLockButton)
    {
        mLockButton->setVisible(mLockButton->isChecked()
            || (mCard.isValid() && mLockButton->geometry().contains(ev->pos())));
    }
    if (mLastLeftClickPos && mCard.isValid())
    {
        QLineF moveLine(ev->globalPos(), *mLastLeftClickPos);
        if (moveLine.length() >= QApplication::startDragDistance())
        {
            QDrag *drag = new QDrag(this);
            QMimeData *dragData = createCardLabelDropData(*this);
            drag->setMimeData(dragData);
            drag->setHotSpot(ev->pos());

            const QPixmap *unitImg = pixmap();
            if (unitImg)
            {
                int w = unitImg->width() / 2;
                int h = unitImg->height() / 2;
                QPixmap dragImg(w, h);
                dragImg.fill(Qt::transparent);
                QPainter painter(&dragImg);
                painter.setOpacity(0.75);
                painter.drawPixmap(0, 0, w, h, unitImg->scaled(w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation));
                painter.end();
                drag->setPixmap(dragImg);
            }

            if (QApplication::keyboardModifiers() == Qt::ControlModifier || !acceptDrops())
            {     
                drag->exec(Qt::CopyAction);
            }
            else
            {
                CCard cardBuf = mCard;
                bool lockBuf = isLocked();
                setCard(CCard::INVALID_CARD);
                setLocked(false);
                if (!drag->exec(Qt::MoveAction))
                {
                    setCard(cardBuf);
                    setLocked(lockBuf);
                }
            }
            delete mLastLeftClickPos;
            mLastLeftClickPos = 0;
            emit unitDragged();
        }
    }
}
void CCardLabel::updateCardLabelPicture(const CCard& card)
{
    if (mCard.getId() == card.getId())
    {
        setCard(card);
    }
}
void HelloWorld::createCard(PosIndex posIndex) {
  // 新しいカードを作成
  auto card = CardSprite::create();
  card->setCard(getCard());
  card->setPosIndex(posIndex);
  addChild(card, ZORDER_SHOW_CARD);
}
void CCardLabel::dropEvent(QDropEvent *ev)
{
    if (ev && isCardLabelDropData(ev->mimeData()))
    {
        QString textData = ev->mimeData()->html().toLatin1();
        QStringList valueList = textData.split(QRegExp("=|;"));
        if (valueList.size() == 4)
        {
            bool ok1(true);
            bool ok2(true);
            int id = valueList.at(1).toInt(&ok1);
            bool locked = valueList.at(3).toInt(&ok2) == 1;
            if (ok1 && ok2)
            {
                ev->accept();
                const CCard &card = CCardTable::getCardTable().getCardForId(id);
                if (card.isValid())
                {
                    CCard cardBuf = mCard;
                    bool lockBuf = isLocked();
                    setCard(card);
                    setLocked(locked);
                    CCardLabel *source = dynamic_cast<CCardLabel*>(ev->source());
                    if (source && source != this && ev->dropAction() == Qt::MoveAction)
                    {
                        source->setCard(cardBuf);
                        source->setLocked(lockBuf);
                    }
                    emit unitDropped();
                }
            }
        }
    }
}
Пример #5
0
void RoomState::resetCard(int cardId)
{
    Card* newCard = Card::Clone(Sanguosha->getEngineCard(cardId));
    if (newCard == NULL) return;
    setCard(cardId, newCard);
    // newCard->setModified(false);
}
void HelloWorld::createCard(PosIndex posIndex){
    //新しいカードを作成する
    auto card = CardSprite::create();
    card->setCard(getCard());
    card->setPosIndex(posIndex);
    addChild(card, ZORDER_SHOW_CARD);
    //auto card = Sprite::create("card_spades.png");
    //card->setPosition(CARD_1_POS_X + CARD_DISTANCE_X * posIndex.x,
    //                  CARD_1_POS_Y + CARD_DISTANCE_Y * posIndex.y);
    //addChild(card, ZORDER_SHOW_CARD);
}
Пример #7
0
int playerCard(int player[]) 
{
     int i;
     static int num=0; //計算被呼叫次數(發給玩家偶數的牌) 
     if(count==0) //遊戲結束,將num設為初值 
        num=0;
     printf("你抽到了:");
     setCard(player[num]);//將亂數陣列中,第num個數值,傳入setCard() 
     printf("\n");
     sumPLCard(player[num]); //進行玩家點數的加總 
     printf("\n");
     num+=2; //每次執行完+2 
     return num;
}
Пример #8
0
CardFrame::CardFrame(const QString &cardName, QWidget *parent) : QTabWidget(parent), info(nullptr), cardTextOnly(false)
{
    setContentsMargins(3, 3, 3, 3);
    pic = new CardInfoPicture();
    pic->setObjectName("pic");
    text = new CardInfoText();
    text->setObjectName("text");
    connect(text, SIGNAL(linkActivated(const QString &)), this, SLOT(setCard(const QString &)));

    tab1 = new QWidget(this);
    tab2 = new QWidget(this);
    tab3 = new QWidget(this);

    tab1->setObjectName("tab1");
    tab2->setObjectName("tab2");
    tab3->setObjectName("tab3");

    insertTab(ImageOnlyView, tab1, QString());
    insertTab(TextOnlyView, tab2, QString());
    insertTab(ImageAndTextView, tab3, QString());
    connect(this, SIGNAL(currentChanged(int)), this, SLOT(setViewMode(int)));

    tab1Layout = new QVBoxLayout();
    tab1Layout->setObjectName("tab1Layout");
    tab1Layout->setContentsMargins(0, 0, 0, 0);
    tab1Layout->setSpacing(0);
    tab1->setLayout(tab1Layout);

    tab2Layout = new QVBoxLayout();
    tab2Layout->setObjectName("tab2Layout");
    tab2Layout->setContentsMargins(0, 0, 0, 0);
    tab2Layout->setSpacing(0);
    tab2->setLayout(tab2Layout);

    splitter = new QSplitter();
    splitter->setObjectName("splitter");
    splitter->setOrientation(Qt::Vertical);

    tab3Layout = new QVBoxLayout();
    tab3Layout->setObjectName("tab3Layout");
    tab3Layout->setContentsMargins(0, 0, 0, 0);
    tab3Layout->setSpacing(0);
    tab3Layout->addWidget(splitter);
    tab3->setLayout(tab3Layout);

    setViewMode(settingsCache->getCardInfoViewMode());

    setCard(db->getCard(cardName));
}
Пример #9
0
int AICard(int AI[])
{
     int i;
     static int num=1; //計算被呼叫次數(發給電腦奇數的牌) 
     if(add2>15) //當AI點數加總>15則印出AI手中的牌 
     {
         printf("莊家的牌為:");
         for(i=1;i<num;i++) //將亂數陣列中, 第1,3,5...,num 中的數值 ,傳入setCard() 
             if(i%2==1)
                setCard(AI[i]);
         printf("\n\n");
         num=-1; //遊戲結束,將num設為初值 
     }
     else if(add2<=15 && num%2==1) //加總AI手中牌的點數 
         sumAICard(AI[num]);
     num+=2; //每次執行完+2 
     return num;
}
Пример #10
0
AlsaItem::AlsaItem(const AlsaItem &item)
{
  setText(item.text());
  setCard(item.card());
  setDevice(item.device());
}
Пример #11
0
void CardInfoWidget::setCard(AbstractCardItem *card)
{
	setCard(card->getInfo());
}
Пример #12
0
void CardInfoWidget::clear()
{
	setCard(db->getCard());
}
Carte::Carte(QStringList L, QObject* parent) : QObject(parent)
{
    setCard(L);
}
Пример #14
0
void CardInfoWidget::setCard(const QString &cardName)
{
	setCard(db->getCard(cardName));
}
Пример #15
0
void CardLayout::previous(ComponentContainer* const TheContainer)
{   
    setCard((getCard()-1)%TheContainer->getMFChildren()->size());
}
Пример #16
0
void CardLayout::first(ComponentContainer* const TheContainer)
{
    setCard(0);
}
Пример #17
0
CardDetect::CardDetect( MagCard *_card ) {
	aamvaIssuerList();
	if( _card )
		setCard( _card );
}
Пример #18
0
void CardFrame::setCard(const QString &cardName)
{
    setCard(db->getCardBySimpleName(cardName));
}
Пример #19
0
void CardFrame::clearCard()
{
    setCard((CardInfoPtr) nullptr);
}
Пример #20
0
void CardFrame::setCard(AbstractCardItem *card)
{
    if (card) {
        setCard(card->getInfo());
    }
}
Пример #21
0
void TvConfig::selectCard(int card_id)
{
    setCard(card_id);
}
Пример #22
0
void CardLayout::first(const ComponentContainerRefPtr TheContainer)
{
    setCard(0);
}
Пример #23
0
void CardLayout::last(ComponentContainer* const TheContainer)
{
    setCard(TheContainer->getMFChildren()->size()-1);
}
Пример #24
0
void CardLayout::next(const ComponentContainerRefPtr TheContainer)
{
    setCard((getCard()+1)%TheContainer->getMFChildren()->size());
}
Пример #25
0
CardItem::CardItem(const Card *card)
{
    _initialize();
    setCard(card);    
    setAcceptHoverEvents(true);
}
Пример #26
0
CardInfoWidget::CardInfoWidget(ResizeMode _mode, const QString &cardName, QWidget *parent, Qt::WindowFlags flags)
	: QFrame(parent, flags)
	, pixmapWidth(0)
	, aspectRatio((qreal) CARD_HEIGHT / (qreal) CARD_WIDTH)
	, minimized(settingsCache->getCardInfoMinimized()) // Initialize the cardinfo view status from cache.
	, mode(_mode)
	, info(0)
{
	if (mode == ModeGameTab) {
		// Create indexed list of status views for card.
		const QStringList cardInfoStatus = QStringList() << tr("Show card only") << tr("Show text only") << tr("Show full info");
		
		// Create droplist for cardinfo view selection, and set right current index.
		dropList = new QComboBox();
		dropList->addItems(cardInfoStatus);
		dropList->setCurrentIndex(minimized);
		connect(dropList, SIGNAL(currentIndexChanged(int)), this, SLOT(minimizeClicked(int)));
	}

	cardPicture = new QLabel;
	cardPicture->setAlignment(Qt::AlignCenter);

	nameLabel1 = new QLabel;
	nameLabel2 = new QLabel;
	nameLabel2->setWordWrap(true);
	manacostLabel1 = new QLabel;
	manacostLabel2 = new QLabel;
	manacostLabel2->setWordWrap(true);
	cardtypeLabel1 = new QLabel;
	cardtypeLabel2 = new QLabel;
	cardtypeLabel2->setWordWrap(true);
	powtoughLabel1 = new QLabel;
	powtoughLabel2 = new QLabel;
	loyaltyLabel1 = new QLabel;
	loyaltyLabel2 = new QLabel;

	textLabel = new QTextEdit();
	textLabel->setReadOnly(true);

	QGridLayout *grid = new QGridLayout(this);
	int row = 0;
	if (mode == ModeGameTab)
		grid->addWidget(dropList, row++, 1, 1, 1, Qt::AlignRight);
	grid->addWidget(cardPicture, row++, 0, 1, 2);
	grid->addWidget(nameLabel1, row, 0);
	grid->addWidget(nameLabel2, row++, 1);
	grid->addWidget(manacostLabel1, row, 0);
	grid->addWidget(manacostLabel2, row++, 1);
	grid->addWidget(cardtypeLabel1, row, 0);
	grid->addWidget(cardtypeLabel2, row++, 1);
	grid->addWidget(powtoughLabel1, row, 0);
	grid->addWidget(powtoughLabel2, row++, 1);
	grid->addWidget(loyaltyLabel1, row, 0);
	grid->addWidget(loyaltyLabel2, row++, 1);
	grid->addWidget(textLabel, row, 0, -1, 2);
	grid->setRowStretch(row, 1);
	grid->setColumnStretch(1, 1);

	retranslateUi();
	setFrameStyle(QFrame::Panel | QFrame::Raised);
	if (mode == ModeGameTab) {
		textLabel->setMinimumHeight(100);
		setFixedWidth(sizeHint().width());
	} else if (mode == ModePopUp) {
		QDesktopWidget desktopWidget;
		pixmapWidth = desktopWidget.screenGeometry().height() / 3 / aspectRatio;
		setFixedWidth(pixmapWidth + 150);
	} else
		setFixedWidth(250);
	
	setCard(db->getCard(cardName));
	setMinimized(settingsCache->getCardInfoMinimized());
}