/**
 * @brief promptplayerInput asks the player to type in a valid word
 * @param boggle
 */
void promptplayerInput(Boggle& boggle){
    Lexicon lex("EnglishWords.dat");
    string tempWord;

    cout << "It's your turn!" << endl;

    printGrid(boggle);

    printPlayerWords(boggle);

    cout << "Your score: " << boggle.getPlayerScore() << endl;
    cout << "Type a word (or press 1 to quit): ";

    cin >> tempWord;
    //makes the str uppercase
    transform(tempWord.begin(), tempWord.end(),tempWord.begin(), ::toupper);
    clearConsole();
    while(tempWord != "1"){

        printGrid(boggle);

        if(!lex.contains(tempWord)){
            cout << "Not a word in the dictionary" << endl;
        }
        else if (!(boggle.getPlayerWords().find(tempWord) != boggle.getPlayerWords().end())) {
            cout << "Word already used" << endl;
        }
        else if ((tempWord.size() < 4)) {
            cout << "Word is too small" << endl;
        }
        else if (!(boggle.findWordInGrid(tempWord))) {
            cout << "That word can't be formed on this board." << endl;
        }
        else {
            boggle.updateScore(tempWord);
            boggle.insertplayerWord(tempWord);
        }

        printPlayerWords(boggle);

        cout << endl;
        cout << "Your score: " << boggle.getPlayerScore() << endl;

        cout << "Type a word (or press 1 to quit): ";
        cin >> tempWord;

        clearConsole();
        //makes the str uppercase
        transform(tempWord.begin(), tempWord.end(),tempWord.begin(), ::toupper);
    }
}
void Interface::viewComputerXPersons(QString id)
{
    string command_string;
    QString command;
    QString d_id;
    clearConsole();
    printLines();
    printMenuHead("COMPUTER RELATIONS");

    cout << request.outputComputerXPersons(id);

    printSimpleLines();
    cout << "Type 'delete id' to delete relation or leave empty to return" << endl;
    printSimpleLines();
    cout << "Query: ";

    getline(cin, command_string);
    command = request.extractCommand(QString::fromStdString(command_string));
    if(command == "delete")
    {
        d_id = request.extractId(QString::fromStdString(command_string));    
        if(request.deleteRelation(id, d_id))
        {
            string c_name = request.getComputer(id).getName().toStdString();
            string p_name = request.getPerson(d_id).getName().toStdString();
            setStatus("Relation of '" + c_name + "' to '" + p_name + "' deleted!");
        }
        else
        {
            setStatus("Unable to delete relation");
        }
    }
}
Exemple #3
0
	void Console::internalCommand(MyGUI::Widget* _sender, const MyGUI::UString& _key, const MyGUI::UString& _value)
	{
		if (_key == "clear")
		{
			clearConsole();
		}
	}
PythonPanel::PythonPanel(QWidget *parent) : QWidget(parent), _ui(new Ui::PythonPanel), _button(NULL), _animation(NULL) {
  _ui->setupUi(this);
  connect(_ui->clearButton, SIGNAL(clicked()), this, SLOT(clearConsole()));
  connect(_ui->consoleWidget, SIGNAL(textChanged()), this, SLOT(newOutputInConsole()));
  connect(_ui->graphCombo,SIGNAL(currentItemChanged()),this,SLOT(graphComboIndexChanged()));
  tlp::PythonInterpreter::getInstance()->runString(setCurrentGraphFunction);
}
Exemple #5
0
void drawList()
{
	clearConsole();
	if(numEnt) {
		int i, j=((scrolly % ICON_SZ) ? 7 : 6);
		CLAMP(j, 0, numEnt);

		for(i=0; i<j; i++) {
			setConsoleCoo((ICON_SZ/8), i * (ICON_SZ/8) + 2);
			if(list) {
				print("%.*s", 32-(ICON_SZ/8), &list[(begin+i)][ENTRY_NAME]);
			}
		}
	} else {
		print("EMPTY\n");
	}
}
/*
 * Plays one game of Boggle using the given boggle game state object.
 */
void playOneGame(Boggle& boggle) {
    boggle.resetBoard();
    cout << "Would you like to randomize the board? (y/n)" << endl;
    string userChoice;
    getline(cin,userChoice);

    if(toLowerCase(trim(userChoice)) == "y"){
        boggle.randomizeBoard();
    }else{

        string boardSeq;
        do {
            cout << "Please enter a valid sequence of letters to fill the board with" << endl;
            getline(cin,boardSeq);
        } while (!boggle.checkValidBoardSeq(boardSeq));
        boggle.setBoard(boardSeq);

    }
    string guessedWord;
    do {
        clearConsole();
        cout << "It's your turn!" << endl;
        boggle.printBoard();
        boggle.printGuessedWords();
        cout << "Your score: " + to_string(boggle.getPlayerScore()) << endl;
        cout << "Type a word (or press Enter to end your turn): ";

        getline(cin,guessedWord);
        if (boggle.checkGuessedWord(guessedWord)) {
            cout << "You found a new word! \"" + toUpperCase(guessedWord) + "\"" << endl;
        }
    } while (!guessedWord.empty());

    cout << "It's my turn!" << endl;
    boggle.printComputerWords();
    cout << "My score: " + to_string(boggle.getComputerScore()) << endl;
    if (boggle.getComputerScore() > boggle.getPlayerScore()) {
        cout << "Ha ha ha, I destroyed you. Better luck next time, puny human!" << endl;
    } else {
        cout << "Screw you... Puny human!" << endl;
    }

}
Exemple #7
0
/*
 * Function: userTurn
 * --------------------
 * This is the user's turn. Prompt them for random/set board, get their word selections
 * use the boggles obj to check words
 *
 * Preconditions:
 *
 *  @param: word: the word to check
 *  @return: boolean true if valid word
 */
void userTurn(Boggle& boggles) {
    Set<string> humanWords;
    string userInputW;
    //int humanScore = 0;

    while(true) {
        clearConsole();
        // First time through this is skipped, goes to else
        if(userInputW!=""){
            if(boggles.checkWord(userInputW)){
                if(boggles.humanWordSearch(toLowerCase(userInputW))){
                    string statusMessage = "You found a new word! \""+toUpperCase(userInputW)+"\"";
                    BoggleGUI::setStatusMessage(statusMessage);
                    cout << statusMessage<<endl;
                    BoggleGUI::recordWord(userInputW,BoggleGUI::HUMAN);
                } else{
                    string statusMessage = "That word cant be formed on this board!";
                    BoggleGUI::setStatusMessage(statusMessage);
                    cout << statusMessage<<endl;
                }
            } else {
                cout << "You must enter an unfound 4+ letter word from the dictionary." << endl;
            }
        }else {
            string sM =  "It's your turn!";
            BoggleGUI::setStatusMessage(sM);
            cout << sM << endl;
        }
        cout << boggles;

        cout << "Your words (" << boggles.getUserValidStrings().size() << "): " << boggles.getUserValidStrings().toString() << endl;
        cout << "Your score: " << boggles.getScoreHuman() << endl;
        BoggleGUI::setScore(boggles.getScoreHuman(),BoggleGUI::HUMAN);

        userInputW = getLine("Type a word (or enter to stop): ");

        // Enter to stop
        if(userInputW==""){
            break;
        }
    }
}
/**
 * @brief printComputerWords prints the words that computer found and the score that it got
 * @param boggle
 */
void printComputerWords(Boggle& boggle){

    boggle.computerFind();

    set<string> words = boggle.getComputerWords();
    clearConsole();
    cout << "It's my turn!" << endl;
    cout << "My words (" << words.size() << "): " << "{";

    for(set<string>::iterator it = words.begin(); it != words.end(); it++){
        cout << "\""<< *it << "\",";
    }

    cout << "}";
    cout << "\nMy score: "  << boggle.getComputerScore() << endl;
    //If the computer has won the game, taunt the player
    if(boggle.getComputerScore() > boggle.getPlayerScore()){
        cout << "Ha ha ha, I destroyed you. Better luck next time, puny human!" << endl;
    }
}
void Interface::searchResultsComputers(string search_string)
{
    QVector<Computer> search_results = request.searchComputers(QString::fromStdString(search_string));
    clearConsole();
    printLines();
    printMenuHead("SEARCH RESULTS");

    if(search_results.size() > 0)
    {
        for(int i = 0; i < search_results.size(); i++)
        {
            cout << search_results[i] << endl;
        }
    }
    else
    {
        cout << "NO RESULTS(did you forget to prepend search string with a correct searchtype?)" << endl;
    }

    printSettingsStatus();
    printStatus();
}
void Interface::addPerson()
{  
    clearConsole();
    printLines();
    printMenuHead("ADD PERSON");
    Person temp;
    char ch;
    cin >> temp;

    cout << "Are you sure you want to add " << temp.getName().toStdString() << "?(y/n): ";
    cin >> ch;
    if(ch == 'y' || ch == 'Y')
    {
       if(request.addPerson(temp))
       {
            setStatus("\"" + temp.getName().toStdString() + "\" added to computer scientists!");
       }
       else
       {
           setStatus("\"" + temp.getName().toStdString() + "\" could not be added to computer scientists!");
       }
    }
}
Exemple #11
0
/**
 * @brief connect all buttons of the ui
 * @return
 *      void
 */
void DLDConfigureOB::connectSignals ()
{
	// connect menu actions
	connect(mainWindow.actionQuit,		SIGNAL(triggered ()), this, SLOT(close ()));
	connect(mainWindow.actionRefresh,	SIGNAL(triggered ()), this, SLOT(refreshDevices ()));
	connect(mainWindow.actionPreferences,	SIGNAL(triggered ()), this, SLOT(showPreferences ()));
	connect(mainWindow.actionOpenBeaconConfiguratorHelp, SIGNAL(triggered ()), this, SLOT(showHelp()));
	connect(mainWindow.actionAboutQt,	SIGNAL(triggered ()), qApp, SLOT(aboutQt ()));
	connect(mainWindow.actionAboutOpenBeacon,SIGNAL(triggered ()), this, SLOT(aboutOpenBeacon ()));

	// connect main Window buttons with methods
	connect(mainWindow.selectFileButton,	SIGNAL(clicked ()), this, SLOT(selectFlashImage ()));
	connect(mainWindow.flashButton,		SIGNAL(clicked ()), this, SLOT(flashDevice ()));
	connect(mainWindow.refreshButton,	SIGNAL(clicked ()), this, SLOT(refreshDevices ()));
	connect(mainWindow.executeButton,	SIGNAL(clicked ()), this, SLOT(executeCommand ()));
	connect(mainWindow.clearButton,		SIGNAL(clicked ()), this, SLOT(clearConsole ()));

	// connect box signals
	connect(mainWindow.commandCombo,	SIGNAL(highlighted (int)), this, SLOT(commandHighlighted (int)));
	connect(mainWindow.commandCombo,	SIGNAL(currentIndexChanged (int)), this, SLOT(updateCommandBoxStatusTip (int)));
	connect(mainWindow.deviceCombo,		SIGNAL(currentIndexChanged (int)), this, SLOT(updateGroupBoxVisibility (int)));
	connect(mainWindow.deviceCombo,		SIGNAL(activated (int)), this, SLOT(openNewDevice (int)));

	// connect device
	connect(device,				SIGNAL(newData (QString)), this, SLOT(receivedNewData (QString)));
	connect(device,				SIGNAL(writeFailed ()), this, SLOT(writeFailed ()));

	// connect internal signals
	connect(this,		SIGNAL(deviceSelected (bool, bool)),	this, SLOT(endisableGroupBox (bool, bool)));
	connect(this,		SIGNAL(commandListChanged ()),		this, SLOT(refillCommandList ()));
	connect(this,		SIGNAL(devicepathsChanged ()),		this, SLOT(refreshDevices ()));
	connect(refreshTimer,	SIGNAL(timeout()),			this, SLOT(refreshDevices ()));
	connect(this,		SIGNAL(logFileChanged (QString)),	this, SLOT(changeLogFile (QString)));
	connect(batchProcess,	SIGNAL(readyReadStandardOutput ()),	this, SLOT(addCharToConsole ()));
	connect(batchProcess,	SIGNAL(error (QProcess::ProcessError)),	this, SLOT(printProcessError (QProcess::ProcessError)));
	connect(batchProcess,	SIGNAL(finished (int, QProcess::ExitStatus)),this, SLOT(processFinished (int, QProcess::ExitStatus)));
}
Exemple #12
0
int  extra
  (void* foo)
{
	const wchar_t* labels[] = {
		L"Chargement du système de jeu",
		L"Chargement de l’interface",
		L"Chargement des modules",
		L"Configuration des préférences",
		L"Initialisation des paramètres globaux"
	};
	
	/* Mouhaha. */
	clearConsole();
	
	for(size_t i = 0;  i < sizeof(labels)/sizeof(*labels);  i++)
		loadModule(labels[i]);
	
	SDL_Delay(1500);
	fputws(asciiArt, stdout);
	fputwc(L'\n', stdout);
	SDL_Delay(1000);
	
	return 0xf00;
}
Exemple #13
0
void redrawKeyConfigChooser() {
    int& option = keyConfigChooser_option;
    KeyConfig* config = &keyConfigs[selectedKeyConfig];

    clearConsole();

    iprintf("Config: ");
    if (option == -1)
        iprintfColored(CONSOLE_COLOR_LIGHT_YELLOW, "* %s *\n\n", config->name);
    else
        iprintf("  %s  \n\n", config->name);

    iprintf("       Button   Function\n\n");

    for (int i=0; i<NUM_BINDABLE_BUTTONS; i++) {
#if defined(_3DS)
       // These button bits aren't assigned to anything, so no strings for them
       if((i > 15 && i < 24) || i == 12 || i == 13)
            continue;
#endif

        int len = 11-strlen(dsKeyNames[i]);
        while (len > 0) {
            iprintf(" ");
            len--;
        }
        if (option == i) 
            iprintfColored(CONSOLE_COLOR_LIGHT_YELLOW, "* %s | %s *\n", dsKeyNames[i], gbKeyNames[config->funcKeys[i]]);
        else
            iprintf("  %s | %s  \n", dsKeyNames[i], gbKeyNames[config->funcKeys[i]]);
    }
    iprintf("\nPress X to make a new config.");
    if (selectedKeyConfig != 0) /* can't erase the default */ {
        iprintf("\n\nPress Y to delete this config.");
    }
}
Exemple #14
0
EmacsWindowWin32::EmacsWindowWin32()
    : _overwriting(false), _ovy(0), _ovx(0),
      _curr_colour_pair(0),
      _fore(15), _back(0),
      _wsp_fore(15), _show_wsp(false),
      _ctrl_fore(11),
      _old_fore(-1), _old_back(-1),
      _botScrollPercent(0), _topScrollPercent(0) {
    hStdIn = ::GetStdHandle(STD_INPUT_HANDLE);
    if (hStdIn != INVALID_HANDLE_VALUE)
        ::SetConsoleMode(hStdIn, ENABLE_MOUSE_INPUT | ENABLE_WINDOW_INPUT);
    hStdOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
    if (hStdOut != INVALID_HANDLE_VALUE) {
        ::SetConsoleMode(hStdOut, 0);
        _has_colours = true;
    } else {
        _has_colours = false;
    }
    clearConsole();

    // Fill out the defaults
    _decode_key[0x00] = MintString("C-@");
    for (mintchar_t i = 1; i < 32; ++i) {
        MintString key("C-");
        key.append(1, static_cast<mintchar_t>(i+'a'-1));
        _decode_key[i] = key;
    } // for
    for (mintchar_t i = 32; i < 127; ++i) {
        _decode_key[i] = MintString(1, i);
    } // for
    // Now fill in the specials
    _decode_key['\b'] = MintString("Back Space");
    _decode_key['\t'] = MintString("Tab");
    _decode_key['\n'] = MintString("Return");
    _decode_key['\r'] = MintString("Return");
    _decode_key[0x1B] = MintString("Escape");
    // ASCII keys that are inconvenient to do in ASCII
    _decode_key[','] = MintString("Comma");
    _decode_key['('] = MintString("LPar");
    _decode_key[')'] = MintString("RPar");
    // NCURSES decodes
    _decode_key[VK_DOWN     ] = MintString("Down Arrow");
    _decode_key[KEY_UP       ] = MintString("Up Arrow");
    _decode_key[KEY_LEFT     ] = MintString("Left Arrow");
    _decode_key[KEY_RIGHT    ] = MintString("Right Arrow");
    _decode_key[KEY_HOME     ] = MintString("Home");
    _decode_key[KEY_BACKSPACE] = MintString("Back Space");
    _decode_key[KEY_F(1)     ] = MintString("F1");
    _decode_key[KEY_F(2)     ] = MintString("F2");
    _decode_key[KEY_F(3)     ] = MintString("F3");
    _decode_key[KEY_F(4)     ] = MintString("F4");
    _decode_key[KEY_F(5)     ] = MintString("F5");
    _decode_key[KEY_F(6)     ] = MintString("F6");
    _decode_key[KEY_F(7)     ] = MintString("F7");
    _decode_key[KEY_F(8)     ] = MintString("F8");
    _decode_key[KEY_F(9)     ] = MintString("F9");
    _decode_key[KEY_F(10)    ] = MintString("F10");
    _decode_key[KEY_F(11)    ] = MintString("F11");
    _decode_key[KEY_F(12)    ] = MintString("F12");
    _decode_key[KEY_F(13)    ] = MintString("S-F1");
    _decode_key[KEY_F(14)    ] = MintString("S-F2");
    _decode_key[KEY_F(15)    ] = MintString("S-F3");
    _decode_key[KEY_F(16)    ] = MintString("S-F4");
    _decode_key[KEY_F(17)    ] = MintString("S-F5");
    _decode_key[KEY_F(18)    ] = MintString("S-F6");
    _decode_key[KEY_F(19)    ] = MintString("S-F7");
    _decode_key[KEY_F(20)    ] = MintString("S-F8");
    _decode_key[KEY_F(21)    ] = MintString("S-F9");
    _decode_key[KEY_F(22)    ] = MintString("S-F10");
    _decode_key[KEY_F(23)    ] = MintString("S-F11");
    _decode_key[KEY_F(24)    ] = MintString("S-F12");
    _decode_key[KEY_DC       ] = MintString("Del");
    _decode_key[KEY_IC       ] = MintString("Ins");
    _decode_key[KEY_NPAGE    ] = MintString("Pg Dn");
    _decode_key[KEY_PPAGE    ] = MintString("Pg Up");
    _decode_key[KEY_END      ] = MintString("End");
} // EmacsWindow
void Interface::doCommand(QString command_string, char type)
{
    QString command = request.extractCommand(command_string);
    QString id = request.extractId(command_string);

    clearConsole();
    printLines();


    if(type == 'p') //PERSON
    {
        if(request.getPerson(id).getId().isEmpty()) //needed to prevent crashes
        {
            setStatus("Person #" + id.toStdString() + " does not exist or is omitted!");
            return;
        }

        printMenuHead(command.toUpper().toStdString() + " PERSON");

        if(command == "edit")
        {
            editPerson(id);
        }
        else if(command == "delete")
        {
            deletePerson(id);
        }
        else if(command == "addr")
        {
            addPersonRelation(id);
        }
        else if(command == "viewr")
        {
            viewPersonXComputers(id);
        }
    }
    else if(type == 'c') //COMPUTER
    {
        if(request.getComputer(id).getId().isEmpty()) //needed to prevent crashes
        {
            setStatus("Computer #" + id.toStdString() + " does not exist!");
            return;
        }

        printMenuHead(command.toUpper().toStdString() + " COMPUTER");

        if(command == "edit")
        {
            editComputer(id);
        }
        else if(command == "delete")
        {
            deleteComputer(id);
        }
        else if(command == "addr")
        {
            addComputerRelation(id);
        }
        else if(command == "viewr")
        {
            viewComputerXPersons(id);
        }
    }
}
bool showStepByStep( T_Cell cell, T_Cell grid[][GRID_SIZE] ) {
	bool retval; // La valeur de retour, vrai si l'utilisateur a choisi de revenir en arriere
	int currentChoice = 1; // Chaque choix dans le menu a un numero
	int userChoice; // Le choix de l'uilisateur
	bool outOf=false; // booleen permet de sortir de la boucle
	do {
		printf("\n");
		//printf("\033[u");
		clearConsole();
		//system("clear"); // Initialiser le terminal
		retval = false; // Valeur faux par default
		printGrid(&cell, grid); // Afficher la grille
		
		if (currentChoice==1) // Si le choix courant egale au numero de menu 
			printf("\033[36m[*] CONTINUER\033[0m\n"); // afficher le menu coloré
		else
			printf("[ ] Continuer\n"); // sinon affichage normal
		if (currentChoice==2)
			printf("\033[36m[*] SAUVGARDER LA GRILLE DANS UN FICHIER\033[0m\n");
		else 
			printf("[ ] Sauvgarder la grille dans un fichier\n");
		if (currentChoice==3)
			printf("\033[36m[*] REVENIRE A L'ETAPE PRECEDENTE\033[0m\n");
		else 
			printf("[ ] Revenir a l'etape precedente\n");
		if (currentChoice==4)
			printf("\033[36m[*] APPLIQUER UNE REGLE\033[0m\n");
		else
			printf("[ ] Appliquer une regle\n");
		if (currentChoice==5)
			printf("\033[36m[#] QUITTER\033[0m \n");
		else
			printf("[ ] Quiter\n");
		
		
		userChoice=getTouch(); // prend le numero de la touche qui l'utilisateur a choisi
		switch (userChoice) { //faire un switch pour le code de la touche
			case 300: { // 300 si la valeur renvoyer par la fonction getTouch() ou cas ou l'utilisateur choisi la fleche haut
				if (currentChoice>1) 
					currentChoice--;
				else
					currentChoice=5;
				break;
			}
			case 301: {
				if (currentChoice<5) 
					currentChoice++;
				else 
					currentChoice=1;
				break;
			}
			default: {
				if (userChoice=='\n' || userChoice=='\r') { // si l'utilisateur a choisi un choix
					switch (currentChoice) {
						case 1: { outOf=true; break;} // continuer
						case 2: { exportCurrentGrid(grid); break; }; // exporter la grille courante
						case 3: {outOf=true; retval=true; break;} // revenir en arriere
						case 4: { // le choix d'application une regle
							bool secondOutOf=false; // booleen permet de sortir de la boucle suivante
							printf("\n  [ Entrer le numero de la regle] : ");
							do {
								int ruleNumber; // le numero de la regle
								ruleNumber=getch(); 
								switch (ruleNumber) {
									case '1': { // regle 1
										secondOutOf = true; // sortire de boucle apres l'application de la regle
										firstRule(grid); // appliquer la regle 2
										printf("\nregle 1 applique avec succes!\ntaper une touche pour continuer... ");
										getTouch(); // attender un signal pour continue
										break;
									} // end of case '1'
									case '2': { // regle 2
										secondOutOf = true;
										secondRule(grid, false);
										printf("\nregle 2 applique avec succes!\ntaper une touche pour continuer... ");
										getTouch();
										break;
									} // end of case '2'
									case '3': { // regle 3
										secondOutOf = true;
										thirdRule(grid, false);
										printf("\nregle 3 applique avec succes!\ntaper une touche pour continuer... ");
										getTouch();
										break;
									} // end of case '3'
									case '4': { // regle 4
										secondOutOf = true;
										forthRule(grid);
										printf("\nregle 4 applique avec succes!\ntaper une touche pour continuer... ");
										getTouch();
										break;
									} // end of case '4'
									default: break;
								} // end of switch ruleNumber
							}while (!secondOutOf);
							break;} // end of case 4
						case 5: {
							printf("\n");
							exit(EXIT_SUCCESS);
						} // end of case 5
						default: break;
					} // end of currentChoice
				} // end of default
			}
		} // end of switchuserchoice
		
	} while (!outOf);
	return  retval;
}
void scanGridValues(T_Cell grid[][GRID_SIZE], bool importFromFile) {
	bool outOf=false;
	int line, column;
	line = 0; column=0;
	int userChoise;
	if (!importFromFile) {
		//printf("\nSaisie les %d valeurs de la grille: ",GRID_SIZE*GRID_SIZE);
		do 
		{
			//system("clear"); // initialiser le terminal
			//printf("\033[u");
			clearConsole();
			printGrid(&grid[line][column], grid); // Afficher la grille
			printf("Entrer la valeur de la case [%d][%d]: ",line,column);
			userChoise = getTouch(); // scan la valeur
			switch (userChoise) { // pour deplacer entre les case de la grille
				case 300: { // touche UP
					if (line>0)
						line--;
					break;
				}
				case 301: { // Touche DOWN
					if (line<GRID_SIZE-1)
						line++;
					break;
				}
				case 302: { // touche RIGHT
					if (column<GRID_SIZE-1)
						column++;
					break;
				}
				case 303: { // touche LEFT
					if (column>0) 
						column--;
					break;
				}
				case '0': { // Effacer la valeur de la case acctuelle
					grid[line][column].value = userChoise-48;
					break;
				}
				default: { // les 9 valeurs possible de la case
					if (userChoise>'0' && userChoise<='9') {
						if (addPossible(userChoise-48, grid[line][column], grid))
							grid[line][column].value = userChoise-48;
						break;
					}
					else if (userChoise=='\n' || userChoise=='\r') { // resoudre la grille
						outOf = true;
						break;
					}
					else {
						outOf=false;
						break;
					}
				}
			}
		} while (!outOf);
	} // end of if no importFromFile
	else importGrid(grid);
	firstRule(grid); // Appliquer la regle 1
}
Exemple #18
0
int8_t Screen::init( uint8_t backScrollPages, uint8_t initWrapMode ) {

#ifdef __TURBOC__
    // Detect the current screen rows
    struct text_info ti;
    gettextinfo( &ti );

    ScreenRows = ti.screenheight;

    // What video mode are we in?

    if ( ti.currmode == MONO ) {
        // Monochrome is current
        colorCard = 0;
        Screen_base = (uint8_t far *)MK_FP( 0xb000, 0 );
    }
    else {
        colorCard = 1;
        Screen_base = (uint8_t far *)MK_FP( 0xb800, 0 );
    }
#else

    // This always works:
    unsigned char mode = *((unsigned char far *)MK_FP( 0x40, 0x49 ));

    if ( mode == 7 ) {
        colorCard = 0;
        Screen_base = (uint8_t far *)MK_FP( 0xb000, 0 );
    }
    else {
        colorCard = 1;
        Screen_base = (uint8_t far *)MK_FP( 0xb800, 0 );
    }

    // Call int 10, ah=12 for EGA/VGA config

    union REGS inregs, outregs;
    struct SREGS segregs;

    inregs.h.ah = 0x12;
    inregs.h.bl = 0x10;
    int86x( 0x10, &inregs, &outregs, &segregs );

    if ( outregs.h.bl == 0x10 ) {
        // Failed.  Must be MDA or CGA
        ScreenRows = 25;
    }
    else {
        ScreenRows = *((unsigned char far *)MK_FP( 0x40, 0x84 )) + 1;
    }

#endif


    // By this point we have an 80 column screen.  The number of rows is
    // also known, and we know if we are on a color display or a 5151.

    ScreenCols = SCREEN_COLS;

    terminalLines = ScreenRows;
    terminalCols = ScreenCols;


    // Setup the virtual buffer.  The virtual buffer also serves as the
    // backscroll buffer.  We need to clear the buffer and set the char
    // attributes to something predictable for at least the virtual screen
    // part.  I do the entire buffer here because I am lazy.

    // Desired size of virtual buffer
    uint32_t desiredBufferSize = backScrollPages * terminalLines;
    desiredBufferSize = desiredBufferSize * BYTES_PER_LINE;

    if ( desiredBufferSize > 64001ul ) {
        // Too much .. get them into 64K
        uint16_t newBackScrollPages = 64000ul / (terminalLines * BYTES_PER_LINE );
        backScrollPages = newBackScrollPages;
    }


    totalLines = terminalLines * backScrollPages;

    bufferSize = totalLines * BYTES_PER_LINE;

    buffer = (uint8_t *)malloc( bufferSize );

    if ( buffer == NULL ) return -1;

    for ( uint16_t i=0; i < bufferSize; i=i+2 ) {
        buffer[i] = 32;
        buffer[i+1] = 7;
    }

    // Used to quickly detect when we are past the end of our buffer.
    bufferEnd = buffer + bufferSize;

    wrapMode = initWrapMode;

    cursor_x = 0;
    cursor_y = 0;
    curAttr = 7;

    topOffset = 0;
    backScrollOffset = 0;

    updateRealScreen = 1;
    virtualUpdated = 0;

    // We are going to keep this up to date instead of computing it for each
    // character.
    vidBufPtr = Screen_base + ( ((cursor_x<<1) + (cursor_y<<7) + (cursor_y<<5)) );

    overhang = false;


    clearConsole( );
    gotoxy( 0, 0 );


    // Terminal emulation state

    scrollRegion_top = 0;       // The host sends these as 1 based; we use 0 for a base.
    scrollRegion_bottom = terminalLines - 1;

    originMode = false;
    autoWrap = false;

    return 0;
}
Exemple #19
0
//mainfunctions of the game
void playOneGame(Boggle& boggle) {
    string input="";
    //runs until a board is generated
    while (1) {
        cout<<endl;
        cout<<"Do you want to generate a random board?: ";
        cin>>input;
        //the user wants to enter an own board
        if (input=="n") {
            //runs until the user has entered a correct board,
            while(1) {
                cout<<"Type the 16 letters to appear on the board:";
                cin>>input;
                vector<string> temp;
                temp=checkInput(input);
                if (temp.size()==16) {
                    for (int i=0; i<16; i++) {
                        boggle.addLetter(temp[i]);
                    }
                    break;
                }
                else {
                    cout<<"That is not a valid 16-letter board String. Try again."<<endl;
                }

            }
            boggle.calculateWords();
            break;
        }
        //if the user wants to autogenerate a board this i used
        if(input=="y") {
            boggle.setupBoardAuto();
            break;
        }
    }
    bool usersTurn=true;
    clearConsole();
    //runs until the user enters "n"
    while (usersTurn) {
        cout<<"it's your turn!"<<endl;
        printBoard(boggle);
        presentUserWords(boggle);
        presentUserScore(boggle);
        input="";
        cout<<"enter a word or  enter n to end your turn:";
        cin>>input;
        //end while loop
        if (input=="n") {
            usersTurn=false;
        }
        else {
            //checks if the word is correct
            if (boggle.addUserWord(input)) {
                //if it is then the score is added to the userscore
                boggle.addUserScore(input.size()-3);
                //says that you have found a new word
                presentNewWord(input);
            }
            else {
                //if it not a correct word then the error is printed out for the user
                cout<<boggle.getUserError()<<endl;
            }
        }
    }
    //prints out with how much the computer has won
    cout<<"It is my turn! now you are going down"<<endl;
    presentComputersWords(boggle);
    boggle.resetBoard();

}
Exemple #20
0
void LuaAVConsole :: clearText() {
	emit clearConsole();
}
Exemple #21
0
LuaAVConsole :: LuaAVConsole()
:	mScriptsLoaded(0),
	mScrolling(true),
	mLogging(false),
	mScriptModel(0),
	mSplitter(0),
	mScriptSplitter(0),
	mTableView(0),
	mCodeEdit(0),
	mTextEdit(0),
	mOpenButton(0),
	mNewButton(0),
	mStatusLabel(0),
	mClearButton(0),
	mScrollButton(0),
	mSelectedScript(-1),
	mStdoutLog(0),
	mStderrLog(0)
{
	// main window properties
	setWindowTitle(QString("LuaAV"));
	setGeometry(300, 600, 650, 375);

	setWindowIcon(QIcon(QPixmap(LUAAV_ICON_PATH)));

	// data model
	mScriptModel = new ScriptModel(this);


	// split scripts and text
	mSplitter = new QSplitter(this);
	mSplitter->setFrameShadow(QFrame::Plain);
	mSplitter->setLineWidth(0);

	setCentralWidget(mSplitter);


	// script splitter
	mScriptSplitter = new QSplitter(this);
	mScriptSplitter->setOrientation(Qt::Vertical);

		// script view
		mTableView = new QTableView(this);
		mTableView->setModel(mScriptModel);
		mTableView->setSortingEnabled(false);
		mTableView->setSelectionBehavior(QAbstractItemView::SelectRows);
		mTableView->horizontalHeader()->hide();
		mTableView->verticalHeader()->hide();
		mTableView->setSelectionMode(QAbstractItemView::SingleSelection);
		mTableView->setWordWrap(true);
		mTableView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
		QPalette pp(mTableView->palette());
		pp.setColor(QPalette::Highlight, QColor(130, 130, 130));
		mTableView->setPalette(pp);
		QFont font(mTableView->font());
		font.setPointSize(8);
		mTableView->setFont(font);
		mScriptSplitter->addWidget(mTableView);

		// code input
		mCodeEdit = new QLineEdit(this);
		QPalette codePalette(mCodeEdit->palette());
		codePalette.setColor(QPalette::Base, QColor(200, 200, 200));
		mCodeEdit->setPalette(codePalette);
	//	mCodeEdit->setFrameShadow(QFrame::Plain);
	//	mCodeEdit->setFrameStyle(QFrame::NoFrame);
	//	mCodeEdit->setLineWidth(0);
		mCodeEdit->insert(QString("print('hello world')"));
		mCodeEdit->setMinimumHeight(MIN_CODE_HEIGHT);
	//	mCodeEdit->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
		mScriptSplitter->addWidget(mCodeEdit);

	mSplitter->addWidget(mScriptSplitter);


	// text window
	mTextEdit = new QTextEdit(this);
	QPalette palette(mTextEdit->palette());
	palette.setColor(QPalette::Base, QColor(140, 140, 140));
	mTextEdit->setPalette(palette);
	mTextEdit->setFrameShadow(QFrame::Plain);
	mTextEdit->setFrameStyle(QFrame::NoFrame);
	mTextEdit->setReadOnly(true);
	mTextEdit->setLineWidth(0);
	mTextEdit->setTabStopWidth(45);
	mSplitter->addWidget(mTextEdit);

	// status buttons and label
	mOpenButton = new QPushButton(this);
	mOpenButton->setText(QString("Open"));

	mNewButton = new QPushButton(this);
	mNewButton->setText(QString("New"));

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

	mClearButton = new QPushButton(this);
	mClearButton->setText(QString("Clear"));

	QAction *clearAction = new QAction(this);
	clearAction->setShortcut(QKeySequence(tr("Ctrl+x")));
	addAction(clearAction);
	connect(clearAction, SIGNAL(triggered()), mClearButton, SLOT(click()));

	mScrollButton = new QPushButton(this);
	mScrollButton->setText(QString("Scroll"));
	mScrollButton->setCheckable(true);


	QStatusBar *status = statusBar();
	status->addWidget(mOpenButton);
	status->addWidget(mNewButton);
	status->addWidget(mStatusLabel, 20);
	status->addWidget(mClearButton);
	status->addWidget(mScrollButton);

	// signal/slot connections
	connect(mTextEdit->verticalScrollBar(), SIGNAL(rangeChanged(int,int)), this, SLOT(scroll()));
	connect(mSplitter, SIGNAL(splitterMoved(int,int)), this, SLOT(resizeTable(int,int)));
	connect(mTableView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(tableViewClicked(const QModelIndex&)));

	connect(mOpenButton, SIGNAL(clicked()), this, SLOT(openFile()));
	connect(mNewButton, SIGNAL(clicked()), this, SLOT(newFile()));
	connect(mClearButton, SIGNAL(clicked()), mTextEdit, SLOT(clear()));
	connect(mScrollButton, SIGNAL(clicked(bool)), this, SLOT(setScrolling(bool)));
	connect(this, SIGNAL(clearConsole()), mTextEdit, SLOT(clear()));
	connect(mCodeEdit, SIGNAL(returnPressed()), this, SLOT(evalCode()));
}