bool Editor::testSave() { // test if a save is required and return true if the app is to continue // false if cancel is selected. (if ok then call out to save the board if (clean) { return true; } int res; res = KMessageBox::warningYesNoCancel(this, i18n("The board has been modified. Would you like t" "o save the changes?"), QString(), KStandardGuiItem::save(),KStandardGuiItem::dontSave()); if (res == KMessageBox::Yes) { // yes to save if (saveBoard()) { return true; } else { KMessageBox::sorry(this, i18n("Save failed. Aborting operation.")); return false; } } else { return (res != KMessageBox::Cancel); } return true; }
void Editor::topToolbarOption(int option) { switch(option) { case ID_TOOL_NEW: newBoard(); break; case ID_TOOL_LOAD: loadBoard(); break; case ID_TOOL_SAVE: saveBoard(); break; case ID_TOOL_LEFT: theBoard.shiftLeft(); repaint(false); break; case ID_TOOL_RIGHT: theBoard.shiftRight(); repaint(false); break; case ID_TOOL_UP: theBoard.shiftUp(); repaint(false); break; case ID_TOOL_DOWN: theBoard.shiftDown(); repaint(false); break; case ID_TOOL_DEL: mode=remove; break; case ID_TOOL_MOVE: mode=move; break; case ID_TOOL_ADD: mode = insert; break; case ID_META_EXIT: close(); break; default: break; } }
// test if a save is required and return true if the app is to continue // false if cancel is selected. (if ok then call out to save the board bool Editor::testSave() { if (clean) return(true); int res; res=KMessageBox::warningYesNoCancel(this, i18n("The board has been modified. Would you " "like to save the changes?"),QString::null,KStdGuiItem::save(),KStdGuiItem::dontSave()); if (res == KMessageBox::Yes) { // yes to save if (saveBoard()) { return true; } else { KMessageBox::sorry(this, i18n("Save failed. Aborting operation.")); } } else { return (res != KMessageBox::Cancel); } return(true); }
int main(int argc, char ** argv) { int do_usage = 0; unsigned int seed = 0; // seed for random setup of the game char * filename = NULL; // to load game from a file chdir( "/home/games/blue" ); printf("\n BLUE. Version 1.0.2\n" " Copyright (c) 2002\n" "Blue comes with ABSOLUTELY NO WARRANTY.\n" "This software is free and you are welcome to redistribute it\n" "under certain conditions; for more details see the file \n" "COPYRIGHT included in the distribution.\n\n"); initGUI(0); while (1) { int c; #ifdef USE_LONG_OPTIONS int option_index = 0; static struct option long_options[] = { {"seed", 1, 0, 's'}, {"file", 1, 0, 'f'}, {0, 0, 0, 0} }; if ( (c = getopt_long (argc, argv, "s:f:", long_options, &option_index)) == -1) #else if ( (c = getopt (argc, argv, "s:f:") ) == -1 ) #endif break; switch (c) { case 's': // seed seed = atoi(optarg); break; case 'f': // file filename = optarg; break; default: do_usage = 1; } } if (do_usage) { printf("Usage: blue [-f file] [-s seed]\n"); } /*init Game*/ initHistory( & theHistory ); resetStrategy(); play_mode = STRATEGY; if (filename) { // printf("load game from %s\n", filename); // TODO : load game from file if ( ( seed = load_game( filename )) < 0) { seed = time( NULL ); // else use the default seed(=time) setgame(seed); saveBoard(); } } else { if (! seed) { seed = time( NULL ); // else use the default seed(=time) } setgame(seed); saveBoard(); } setgui(seed); PlayGame(seed); // play the game( core of the game) return (0); }