Beispiel #1
0
void Player::setGeneral2Name(const QString &general_name){
    const General *new_general = Sanguosha->getGeneral(general_name);
    if(general2 != new_general){
        general2 = new_general;

        emit general_changed();
    }
}
Beispiel #2
0
void Player::setGeneral(const General *new_general) {
    if (this->general != new_general) {
        this->general = new_general;

        if (new_general && kingdom.isEmpty())
            setKingdom(new_general->getKingdom());

        emit general_changed();
    }
}
Beispiel #3
0
void Player::setGeneral(const General *new_general){
    if(this->general != new_general){
        this->general = new_general;
        if(new_general){
            setKingdom(general->getKingdom());
        }

        emit general_changed();
    }
}
Beispiel #4
0
void Dashboard::setPlayer(const ClientPlayer *player){
    connect(player, SIGNAL(state_changed()), this, SLOT(refresh()));
    connect(player, SIGNAL(kingdom_changed()), this, SLOT(updateAvatar()));
    connect(player, SIGNAL(general_changed()), this, SLOT(updateAvatar()));
    connect(player, SIGNAL(action_taken()), this, SLOT(setActionState()));

    mark_item->setDocument(player->getMarkDoc());

    updateAvatar();
}
Beispiel #5
0
void CardItem::changeGeneral(const QString &generalName) {
    setObjectName(generalName);
    const General *general = Sanguosha->getGeneral(generalName);
    if (general) {
        _m_isUnknownGeneral = false;
        setToolTip(general->getSkillDescription(true));
    } else {
        _m_isUnknownGeneral = true;
        setToolTip(QString());
    }
    emit general_changed();
}
Beispiel #6
0
void Player::setGeneralName(const QString &general_name){
    const General *new_general = Sanguosha->getGeneral(general_name);

    if(this->general != new_general){
        this->general = new_general;
        if(new_general){
            setHp(getMaxHP());
            setKingdom(general->getKingdom());
        }

        emit general_changed();
    }
}
void ChooseGeneralBox::chooseGeneral(QStringList generals) {
    //嶷仟紙崙嘘尚
    if (generals.contains("anjiang(lord)")) generals.removeAll("anjiang(lord)");
    general_number = generals.length();
    update();

    items.clear();
    selected.clear();
    foreach(QString general, generals) {
        if (general.endsWith("(lord)")) continue;
        GeneralCardItem *general_item = new GeneralCardItem(general);
        general_item->setFlag(QGraphicsItem::ItemIsFocusable);

        if (single_result)
            general_item->setFlag(QGraphicsItem::ItemIsMovable, false);
        else {
            general_item->setAutoBack(true);
            connect(general_item, SIGNAL(released()), this, SLOT(_adjust()));
        }

        connect(general_item, SIGNAL(clicked()), this, SLOT(_onItemClicked()));
        connect(general_item, SIGNAL(enter_hover()), this, SLOT(_onCardItemHover()));
        connect(general_item, SIGNAL(leave_hover()), this, SLOT(_onCardItemLeaveHover()));
        connect(general_item, SIGNAL(general_changed()), this, SLOT(adjustItems()));

        if (!single_result) {
            const General *hero = Sanguosha->getGeneral(general);
            foreach (QString other, generals) {
                if (other.endsWith("(lord)")) continue;
                if (general != other && hero->isCompanionWith(other)) {
                    general_item->showCompanion();
                    break;
                }
            }
        }

        items << general_item;
        general_item->setParentItem(this);
    }

    setPos(RoomSceneInstance->tableCenterPos() - QPointF(boundingRect().width() / 2, boundingRect().height() / 2));
    show();

    int card_width = G_COMMON_LAYOUT.m_cardNormalWidth;
    int card_height = G_COMMON_LAYOUT.m_cardNormalHeight;
    int first_row = (general_number < 6) ? general_number : ((general_number + 1) / 2);

    for (int i = 0; i < items.length(); ++ i) {
        GeneralCardItem *card_item = items.at(i);

        QPointF pos;
        if (i < first_row) {
            pos.setX(left_blank_width + (card_width + card_to_center_line) * i + card_width / 2);
            pos.setY(top_blank_width + card_height / 2);
        } else {
            if (items.length() % 2 == 1)
                pos.setX(left_blank_width + card_width / 2 + card_to_center_line / 2 
                    + (card_width + card_to_center_line) * (i - first_row) + card_width / 2);
            else
                pos.setX(left_blank_width + (card_width + card_to_center_line) * (i - first_row) + card_width / 2);
            pos.setY(top_blank_width + card_height + card_to_center_line + card_height / 2);
        }

        card_item->setPos(25, 45);
        if (!single_result)
            //委厘社優廖峽贋和栖�契峭指音栖
            card_item->setData(S_DATA_INITIAL_HOME_POS, pos);
        card_item->setHomePos(pos);
        card_item->goBack(true);
    }

    if (single_result)
        confirm->hide();
    else {
        confirm->setPos(boundingRect().center().x() - confirm->boundingRect().width() / 2, boundingRect().height() - 60);
        confirm->show();
    }
    _initializeItems();

    if (ServerInfo.OperationTimeout != 0) {
        if (!progress_bar) {
	        progress_bar = new QSanCommandProgressBar();
	        progress_bar->setMinimumWidth(200);
	        progress_bar->setMaximumHeight(12);
	        progress_bar->setTimerEnabled(true);
	        progress_bar_item = new QGraphicsProxyWidget(this);
	        progress_bar_item->setWidget(progress_bar);
	        progress_bar_item->setPos(boundingRect().center().x() - progress_bar_item->boundingRect().width() / 2, boundingRect().height() - 30);
	        connect(progress_bar, SIGNAL(timedOut()), this, SLOT(reply()));
        }
        progress_bar->setCountdown(QSanProtocol::S_COMMAND_CHOOSE_GENERAL);
        progress_bar->show();
    }
}