Exemplo n.º 1
0
void GameWindow::loadGameButtonClicked()
{
    QString url = QFileDialog::getOpenFileName(this, tr("Select a file"), "./Save/");

    QFile inputFile(url);
    if (inputFile.open(QIODevice::ReadOnly))
    {
        QTextStream in(&inputFile);
        QString buffer = in.readAll();

        clearChessBoard();
        fillChessBoard();

        parsingFile(buffer);

        startGameButton->hide();
        loadGameButton->setGeometry(440,580,120,25);

        prevMoveButton->show();
        nextMoveButton->show();
        newGameButton->show();

        cursor = listOfMoves.end();
        isMoveFlag = false;

        inputFile.close();
    }
}
Exemplo n.º 2
0
void CommandEngine::readFile()
{
	std::ifstream myFile(m_fileName.c_str());
    	
	if(myFile.is_open() ) {

		std::string commandLine;
		std::string text;
		while (myFile.good() )
		{
			getline (myFile, commandLine);
			int indexStartOfChar = commandLine.find_first_not_of(" ");

			if(indexStartOfChar != std::string::npos) {
				commandLine = commandLine.substr(indexStartOfChar, commandLine.size() );
				parsingFile(commandLine);
			} 
		}			
		myFile.close();
  	} else {
	 	std::cout << "Unable to open file"; 

	}  
}