コード例 #1
0
ファイル: battleships.cpp プロジェクト: Kri-7-q/Battleships
/**
 * SLOT
 * Takes a shot from the local player.
 * Places the shot on the oponents board or send the
 * coordinates through the network.
 * @param index
 */
bool Battleships::playersShoot(const int index)
{
    setLocalePlayersTurn(false);
    addShoot();
    bool isHit = false;
    if (m_playerMode == SinglePlayer) {
        const Ship *hiddenShip = m_foesGameBoard->shootAt(index);
        if (hiddenShip) {
            setInfoText("You hit one of the ships.");
        } else {
            setInfoText("You shot into the water.");
        }
        if (! m_foesGameBoard->hasUndestroyedShip()) {
            setWinnerName(playerName());
            setCurrentView("GameOverDialog");
        }
        emit botShoot();
    } else {
        m_indexLastShot = index;
        QJsonObject object;
        object.insert("type", "SHOT");
        QJsonObject options;
        QPoint pt = m_foesGameBoard->getPointObject(index);
        options.insert("x", pt.x());
        options.insert("y", pt.y());
        object.insert("options", options);
        QJsonDocument *message = new QJsonDocument(object);
        emit sendMessage(message);
    }

    return isHit;
}
コード例 #2
0
void IqHelpViewerMainWindow::showPage(const QUrl &url)
{
    qDebug() << tr("Show page \"%0\".")
                .arg(url.toString());
    IqHelpViewWidget *view = NULL;

    if (m_currentView && m_currentView->canShowPage(url)) {
        view = m_currentView;
    }
    else {
        foreach (IqHelpViewWidget *viewCandidate, m_helpViewWidgets) {
            if (!viewCandidate)
                continue;
            if (!viewCandidate->canShowPage(url))
                continue;

            view = viewCandidate;
            break;
        }
    }

    if (view) {
        setCurrentView(view);

        if (view->url() != url) {
            m_urlLineEdit->setText(url.toString());

            view->showPage(url);
        }
    }
}
コード例 #3
0
ファイル: battleships.cpp プロジェクト: Kri-7-q/Battleships
/**
 * Got a finished message over network.
 * Interpret the reason.
 * @param object
 */
void Battleships::finishedMessage(const QJsonObject &object)
{
    QJsonObject options = object.value("options").toObject();
    if (options.value("reason") == "won") {
        setInfoText("You have won the game.");
        setWinnerName(m_playerName);
        setCurrentView("GameOverDialog");
    }
    else if (options.value("reason") == "quit") {
        setWinnerName("No one");
        setCurrentView("GameOverDialog");
    }
    else if (options.value("reason") == "error") {
        // Error ?
    }
    emit closeConnection();
}
コード例 #4
0
void WlanSnifferMainWindow::toListView(const QString &title)
{
    OstTraceFunctionEntry0(WLANSNIFFERMAINWINDOW_TOLISTVIEW_ENTRY);
    
    // Show the list view
    mListView->setTitle(title);
    setCurrentView(mListView);
    show();

    OstTraceFunctionExit0(WLANSNIFFERMAINWINDOW_TOLISTVIEW_EXIT);
}
コード例 #5
0
ファイル: battleships.cpp プロジェクト: Kri-7-q/Battleships
/**
 * Got a game offer replay.
 * If game offer was accepted the game can start.
 * If not accepted ?
 * @param object
 */
void Battleships::gameOfferReplay(const QJsonObject &object)
{
    QJsonObject options = object.value("options").toObject();
    QString name = options.value("player_name").toString();
    bool accepted = options.value("success").toBool();
    if (accepted) {
        m_foesGameBoard->setPlayerName(name);
        setLocalePlayersTurn(true);
        setCurrentView("GamePlayDialog");
    }
}
コード例 #6
0
ファイル: battleships.cpp プロジェクト: Kri-7-q/Battleships
/**
 * Got a game offer.
 * Show terms of game offer on screen and ask the player
 * to accept it.
 * @param object
 */
void Battleships::takeGameOffer(const QJsonObject &object)
{
    QJsonObject options = object.value("options").toObject();
    QStringList list;
    list << options.value("player_name").toString();
    list << options.value("board_size_x").toString();
    list << options.value("board_size_y").toString();
    list << options.value("ships_present").toString();
    setGameOfferValueList(list);
    setCurrentView("GameOfferView");
}
コード例 #7
0
ファイル: DangerScene.cpp プロジェクト: Deanzou/Danger-Live
void DangerScene::changeMode (int mode) {
	
	modeToGo = mode;
	fade();
	return;
	
	
	if ( mode == currentMode ) return;
	currentMode = mode;
	setCurrentView(currentView);
	if ( mode == DGSCENEVIEWMODE_VIDEOS ) videoView.init();
	
}
コード例 #8
0
ファイル: battleships.cpp プロジェクト: Kri-7-q/Battleships
/**
 * Simulates a bot behaviour. Shoots randomly to the locale
 * players game board.
 * @return          True if bot hit a ship.
 */
bool Battleships::botShoot()
{
    ShipPosition position = getRandomShipPosition(m_playersGameBoard->getGameBoardSize());
    const Ship* hiddenShip = m_playersGameBoard->shoot(position.x, position.y);
    if (hiddenShip != 0) {
        setInfoText("One of your ships is hidden.");
    } else {
        setInfoText("Foe shot into the water.");
    }
    if (! m_playersGameBoard->hasUndestroyedShip()) {
        setWinnerName("Foe");
        setCurrentView("GameOverDialog");
    }
    setLocalePlayersTurn(true);

    return (hiddenShip != 0);
}
コード例 #9
0
bool DFileManagerWindowPrivate::cdForTab(Tab *tab, const DUrl &fileUrl)
{
    Q_Q(DFileManagerWindow);

    DFMBaseView *current_view = tab->fileView();

    if (current_view && current_view->rootUrl() == fileUrl) {
        return false;
    }

    // old mount scheme support... may get removed when no other place use this...
    if (fileUrl.scheme() == "mount") {
        DUrl newUrl;
        QUrlQuery query(fileUrl);

        if (query.hasQueryItem("id")) {
            newUrl.setQuery(query.queryItemValue("id"));
            appController->actionOpenDisk(dMakeEventPointer<DFMUrlBaseEvent>(q_ptr, newUrl));

            return true;
        }
    }

    if (!current_view || !DFMViewManager::instance()->isSuited(fileUrl, current_view)) {
        DFMBaseView *view = DFMViewManager::instance()->createViewByUrl(fileUrl);

        if (view) {
            viewStackLayout->addWidget(view->widget());

            if (tab == tabBar->currentTab())
                viewStackLayout->setCurrentWidget(view->widget());

            q_ptr->handleNewView(view);
        } else {
            qWarning() << "Not support url: " << fileUrl;

            //###(zccrs):
            const DAbstractFileInfoPointer &fileInfo = DFileService::instance()->createFileInfo(q_ptr, fileUrl);

            if (fileInfo) {
                /* Call fileInfo->exists() twice. First result is false and the second one is true;
                           Maybe this is a bug of fuse when smb://10.0.10.30/people is mounted and cd to mounted folder immediately.
                        */
                qDebug() << fileInfo->exists() << fileUrl;
                qDebug() << fileInfo->exists() << fileUrl;
            }

            if (!fileInfo || !fileInfo->exists()) {
                DUrl searchUrl = current_view->rootUrl();

                if (searchUrl.isComputerFile()) {
                    searchUrl = DUrl::fromLocalFile("/");
                }

                if (searchUrl.isSearchFile()) {
                    searchUrl = searchUrl.searchTargetUrl();
                }

                if (!q_ptr->isCurrentUrlSupportSearch(searchUrl)) {
                    return false;
                }

                const DUrl &newUrl = DUrl::fromSearchFile(searchUrl, fileUrl.toString());
                const DAbstractFileInfoPointer &fileInfo = DFileService::instance()->createFileInfo(q_ptr, newUrl);

                if (!fileInfo || !fileInfo->exists()) {
                    return false;
                }

                return cdForTab(tab, newUrl);
            }

            return false;
        }

        if (current_view) {
            current_view->deleteLater();
        }

        tab->setFileView(view);

        if (tab == tabBar->currentTab())
            setCurrentView(view);

        current_view = view;
    }

    bool ok = false;

    if (current_view) {
        ok = current_view->setRootUrl(fileUrl);

        if (ok) {
            tab->onFileRootUrlChanged(fileUrl);

            if (tab == tabBar->currentTab()) {
                emit q_ptr->currentUrlChanged();
            }
        }
    }

    return ok;
}
コード例 #10
0
ファイル: navigationbar.cpp プロジェクト: solodyagin/qupzilla
NavigationBar::~NavigationBar()
{
    setCurrentView(nullptr);
}
コード例 #11
0
void IAUpdateMainWindow::toSettingView()
{
    setCurrentView(mSettingView);
}
コード例 #12
0
// Slots to handle view change
void IAUpdateMainWindow::toMainView()
{
    setCurrentView(mMainView);
}
コード例 #13
0
ファイル: battleships.cpp プロジェクト: Kri-7-q/Battleships
/**
 * SLOT
 * Is called when a network error occures.
 * @param error
 */
void Battleships::networkConnectionError(const QString &error)
{
    m_networkConnectionError = error;
    emit networkErrorChanged();
    setCurrentView("NetworkErrorDialog");
}