int main() { int input; printf( "1. Play game\n" ); printf( "2. Load game\n" ); printf( "3. Play multiplayer\n" ); printf( "4. Exit\n" ); printf( "Selection: " ); scanf( "%d", &input ); switch ( input ) { case 1: /* Note the colon, not a semicolon */ playgame(); break; case 2: loadgame(); break; case 3: playmultiplayer(); break; case 4: printf( "Thanks for playing!\n" ); break; default: printf( "Bad input, quitting!\n" ); break; } getchar(); }
int CMD_graph( int argc, char **argv ) { game *aGame; int result; result = EXIT_FAILURE; if ( argc == 4 ) { if ( ( aGame = loadgame( argv[2], atoi( argv[3] ) ) ) ) { player *aPlayer; int number; raceStatus( aGame ); for ( number = 0, aPlayer = aGame->players; aPlayer; aPlayer = aPlayer->next, number++ ) { printf( "%d %d %s %f\n", aGame->turn, number, aPlayer->name, effectiveIndustry( aPlayer->totPop, aPlayer->totInd ) ); } } else { fprintf( stderr, "Could not load game \"%s\" turn %s\n", argv[2], argv[3] ); } } else { usage( ); } return result; }
/** * Renderiza o menu baseado na seleção * \param tela Tela onde o menu será renderizado */ void gunther_menu(SDL_Surface* screen) { int section = TITLE; while (section != QUIT){ switch(section){ case TITLE: section = title(screen); break; case NEWGAME: section = newgame(screen); break; case LOADGAME: section = loadgame(screen); break; case OPTIONS: section = options(screen); break; case MANUAL: section = manual(screen,0); break; case COMMANDS: section = manual(screen,COMMANDS); break; case CREDITS: section = credits(screen); break; default: section = QUIT; } } }
int main() { char ch; welcomescreen(); printrule(); do { switch(mainmenu()) { case 0 :loadgame(); break; case 1: controls(); break; case 2: ; break; } printf("\nDo you want to play now ? ( Y OR N)\n"); scanf("%c",&ch); ch = tolower(ch); } while(ch =='y'); clrscr(); printf("Your score has been saved to Snake.txt\n"); FILE *fp; fp = fopen("Snake.txt", "a"); fprintf(fp,"Player score : %d\n", globscore); printf("\n\nThanks for playing\n"); fclose(fp); return 0 ; }
saveMenu() { int input; printf("*********** PIMP QUEST ***************\n"); printf("1. New Game\n"); printf("2. Load Previous Game\n"); printf("3. Save Game\n"); printf("Selection: "); scanf("%d", &input); switch (input) { case 1: system("cls"); newGame(); break; case 2: system("cls"); loadgame(); break; case 3: system("cls"); saveGame(); break; default: system("cls"); printf("Something happened that wasn't supposed to..exiting."); break; } }
int main() { int input; printf("Welcome!\n"); printf("1. Single Player\n"); printf("2. Multiplayer\n"); printf("3. Load Game\n"); printf("4. Exit\n"); printf("Selection:"); scanf("%d", &input); switch (input) { case 1: singleplayer(); break; case 2: multiplayer(); break; case 3: loadgame(); break; case 4: printf("Thanks for playing!\n"); break; default: printf("Bad input, quitting!\n"); break; } return 0; }
void Script::o_loadgame() { uint16 varnum = readScript8or16bits(); uint8 slot = _variables[varnum]; debugScript(1, true, "LOADGAME var[0x%04X] -> slot=%d (TODO)", varnum, slot); loadgame(slot); _vm->_system->fillScreen(0); }
Common::Error DMEngine::loadGameState(int slot) { if (loadgame(slot) != kM1_LoadgameFailure) { _displayMan->fillScreen(k0_ColorBlack); _displayMan->startEndFadeToPalette(_displayMan->_palDungeonView[0]); _newGameFl = k0_modeLoadSavedGame; startGame(); _restartGameRequest = false; _eventMan->hideMouse(); _eventMan->discardAllInput(); return Common::kNoError; } return Common::kNoGameDataFoundError; }
void DMEngine::initializeGame() { initMemoryManager(); _displayMan->loadGraphics(); _displayMan->initializeGraphicData(); _displayMan->loadFloorSet(k0_FloorSetStone); _displayMan->loadWallSet(k0_WallSetStone); _sound->loadSounds(); // @ F0506_AMIGA_AllocateData if (!ConfMan.hasKey("save_slot")) // skip drawing title if loading from launcher drawTittle(); _textMan->initialize(); _objectMan->loadObjectNames(); _eventMan->initMouse(); int16 saveSlot = -1; do { // if loading from the launcher if (ConfMan.hasKey("save_slot")) { saveSlot = ConfMan.getInt("save_slot"); } else { // else show the entrance processEntrance(); if (_engineShouldQuit) return; if (_newGameFl == k0_modeLoadSavedGame) { // if resume was clicked, bring up ScummVM load screen GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); saveSlot = dialog->runModalWithCurrentTarget(); delete dialog; } } } while (loadgame(saveSlot) != k1_LoadgameSuccess); _displayMan->loadIntoBitmap(k11_MenuSpellAreLinesIndice, _menuMan->_bitmapSpellAreaLines); // @ F0396_MENUS_LoadSpellAreaLinesBitmap // There was some memory wizardy for the Amiga platform, I skipped that part _displayMan->allocateFlippedWallBitmaps(); startGame(); if (_newGameFl) _moveSens->getMoveResult(Thing::_party, kM1_MapXNotOnASquare, 0, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY); _eventMan->showMouse(); _eventMan->discardAllInput(); }
screen_id setup_game_screen(atg_canvas *canvas, game *state) { atg_event e; int i; #ifndef WINDOWS if(chdir(localdat?cwd:DATIDIR)) { perror("Failed to enter data dir: chdir"); return(1); } #endif while(1) { SG_acbox->hidden=(selstart<0); for(i=0;i<(int)nstarts;i++) { atg_box *tb=SG_stitles[i]->elemdata; if(tb) { if(i==selstart) tb->bgcolour=(atg_colour){47, 63, 79, ATG_ALPHA_OPAQUE}; else tb->bgcolour=(atg_colour){47, 47, 47, ATG_ALPHA_OPAQUE}; } } atg_ebox_empty(SG_text_box); if(selstart>=0) { snprintf(SG_datestring, 11, "%02u-%02u-%04u", state->now.day, state->now.month, state->now.year); const char *bodytext=starts[selstart].description; size_t x=0; while(bodytext && bodytext[x]) { size_t l=strcspn(bodytext+x, "\n"); if(!l) break; char *t=strndup(bodytext+x, l); atg_element *r=atg_create_element_label(t, 10, (atg_colour){0, 0, 0, ATG_ALPHA_OPAQUE}); free(t); if(!r) { fprintf(stderr, "atg_create_element_label failed\n"); break; } if(atg_ebox_pack(SG_text_box, r)) { perror("atg_ebox_pack"); atg_free_element(r); break; } x+=l; if(bodytext[x]=='\n') x++; } for(unsigned int i=0;i<ntypes;i++) { unsigned int count=0; for(unsigned int j=0;j<state->nbombers;j++) if(state->bombers[j].type==i) count++; if(SG_btnum[i]) snprintf(SG_btnum[i], 8, "%u", count); if(SG_btrow[i]) SG_btrow[i]->hidden=!count; } for(unsigned int i=0;i<nftypes;i++) { unsigned int count=0; for(unsigned int j=0;j<state->nfighters;j++) if(state->fighters[j].type==i) count++; if(SG_ftnum[i]) snprintf(SG_ftnum[i], 8, "%u", count); if(SG_ftrow[i]) SG_ftrow[i]->hidden=!count; } } else { snprintf(SG_datestring, 11, " - - "); } atg_flip(canvas); while(atg_poll_event(&e, canvas)) { switch(e.type) { case ATG_EV_RAW:; SDL_Event s=e.event.raw; switch(s.type) { case SDL_QUIT: return(SCRN_MAINMENU); case SDL_VIDEORESIZE: mainsizex=canvas->surface->w; mainsizey=canvas->surface->h; break; } break; case ATG_EV_CLICK:; atg_ev_click c=e.event.click; for(i=0;i<(int)nstarts;i++) if(c.e==SG_stitles[i]) break; if(i<(int)nstarts) { selstart=i; fprintf(stderr, "Loading game state from '%s'...\n", starts[i].filename); if(loadgame(starts[i].filename, state)) { fprintf(stderr, "Failed to load from start file\n"); selstart=-1; } } else if(c.e==SG_full) { fullscreen=!fullscreen; atg_setopts_canvas(canvas, fullscreen?SDL_FULLSCREEN:SDL_RESIZABLE); } else if (c.e==SG_exit) return(SCRN_MAINMENU); else if(c.e) { unsigned int j; for(j=0;j<ntypes;j++) if(c.e==SG_btint[j]) break; if(j<ntypes) { IB_i=j; intel_caller=SCRN_SETPGAME; return(SCRN_INTELBMB); } else { for(j=0;j<nftypes;j++) if(c.e==SG_ftint[j]) break; if(j<nftypes) { IF_i=j; intel_caller=SCRN_SETPGAME; return(SCRN_INTELFTR); } else { fprintf(stderr, "Clicked on unknown clickable!\n"); } } } break; case ATG_EV_TRIGGER:; atg_ev_trigger trigger=e.event.trigger; if(trigger.e==SG_cont) { for(unsigned int i=0;i<ntypes;i++) state->btypes[i]=!types[i].extra; difficulty_show_only=false; return(SCRN_SETPDIFF); } else if(!trigger.e) { // internal error } else fprintf(stderr, "Clicked on unknown button!\n"); break; default: break; } } SDL_Delay(50); } }
void DMEngine::endGame(bool doNotDrawCreditsOnly) { static Box boxEndgameRestartOuterEN(103, 217, 145, 159); static Box boxEndgameRestartInnerEN(105, 215, 147, 157); static Box boxEndgameRestartOuterDE(82, 238, 145, 159); static Box boxEndgameRestartInnerDE(84, 236, 147, 157); static Box boxEndgameRestartOuterFR(100, 220, 145, 159); static Box boxEndgameRestartInnerFR(102, 218, 147, 157); Box restartOuterBox; Box restartInnerBox; switch (getGameLanguage()) { // localized default: case Common::EN_ANY: restartOuterBox = boxEndgameRestartOuterEN; restartInnerBox = boxEndgameRestartInnerEN; break; case Common::DE_DEU: restartOuterBox = boxEndgameRestartOuterDE; restartInnerBox = boxEndgameRestartInnerDE; break; case Common::FR_FRA: restartOuterBox = boxEndgameRestartOuterFR; restartInnerBox = boxEndgameRestartInnerFR; break; } static Box theEndBox(120, 199, 95, 108); static Box championMirrorBox(11, 74, 7, 49); static Box championPortraitBox(27, 58, 13, 41); bool waitBeforeDrawingRestart = true; _eventMan->setMousePointerToNormal(k0_pointerArrow); _eventMan->showMouse(); _eventMan->_primaryMouseInput = nullptr; _eventMan->_secondaryMouseInput = nullptr; _eventMan->_primaryKeyboardInput = nullptr; _eventMan->_secondaryKeyboardInput = nullptr; if (doNotDrawCreditsOnly && !_gameWon) { _sound->requestPlay(k06_soundSCREAM, _dungeonMan->_partyMapX, _dungeonMan->_partyMapY, k0_soundModePlayImmediately); delay(240); } if (_displayMan->_paletteSwitchingEnabled) { uint16 oldPalTopAndBottomScreen[16]; for (uint16 i = 0; i < 16; ++i) oldPalTopAndBottomScreen[i] = _displayMan->_paletteTopAndBottomScreen[i]; for (int i = 0; i <= 7; i++) { delay(1); for (int colIdx = 0; colIdx < 16; colIdx++) { _displayMan->_paletteMiddleScreen[colIdx] = _displayMan->getDarkenedColor(_displayMan->_paletteMiddleScreen[colIdx]); _displayMan->_paletteTopAndBottomScreen[colIdx] = _displayMan->getDarkenedColor(_displayMan->_paletteTopAndBottomScreen[colIdx]); } } _displayMan->_paletteSwitchingEnabled = false; delay(1); for (uint16 i = 0; i < 16; ++i) _displayMan->_paletteTopAndBottomScreen[i] = oldPalTopAndBottomScreen[i]; } else _displayMan->startEndFadeToPalette(_displayMan->_blankBuffer); uint16 darkBluePalette[16]; if (doNotDrawCreditsOnly) { if (_gameWon) { // Strangerke: Related to portraits. Game data could be missing for earlier versions of the game. _displayMan->fillScreen(k12_ColorDarkestGray); for (int16 championIndex = k0_ChampionFirst; championIndex < _championMan->_partyChampionCount; championIndex++) { int16 textPosY = championIndex * 48; Champion *curChampion = &_championMan->_champions[championIndex]; _displayMan->blitToScreen(_displayMan->getNativeBitmapOrGraphic(k208_wallOrn_43_champMirror), &championMirrorBox, k32_byteWidth, k10_ColorFlesh, 43); _displayMan->blitToScreen(curChampion->_portrait, &championPortraitBox, k16_byteWidth, k1_ColorDarkGary, 29); _textMan->printEndGameString(87, textPosY += 14, k9_ColorGold, curChampion->_name); int textPosX = (6 * strlen(curChampion->_name)) + 87; char championTitleFirstCharacter = curChampion->_title[0]; if ((championTitleFirstCharacter != ',') && (championTitleFirstCharacter != ';') && (championTitleFirstCharacter != '-')) textPosX += 6; _textMan->printEndGameString(textPosX, textPosY++, k9_ColorGold, curChampion->_title); for (int16 idx = k0_ChampionSkillFighter; idx <= k3_ChampionSkillWizard; idx++) { uint16 skillLevel = MIN<uint16>(16, _championMan->getSkillLevel(championIndex, idx | (k0x4000_IgnoreObjectModifiers | k0x8000_IgnoreTemporaryExperience))); if (skillLevel == 1) continue; char displStr[20]; strcpy(displStr, _inventoryMan->_skillLevelNames[skillLevel - 2]); strcat(displStr, " "); strcat(displStr, _championMan->_baseSkillName[idx]); _textMan->printEndGameString(105, textPosY = textPosY + 8, k13_ColorLightestGray, displStr); } championMirrorBox._y1 += 48; championMirrorBox._y2 += 48; championPortraitBox._y1 += 48; championPortraitBox._y1 += 48; } _displayMan->startEndFadeToPalette(_displayMan->_paletteTopAndBottomScreen); _engineShouldQuit = true; return; } T0444017: _displayMan->fillScreen(k0_ColorBlack); _displayMan->blitToScreen(_displayMan->getNativeBitmapOrGraphic(k6_theEndIndice), &theEndBox, k40_byteWidth, kM1_ColorNoTransparency, 14); for (uint16 i = 0; i < 16; ++i) darkBluePalette[i] = D01_RGB_DARK_BLUE; uint16 curPalette[16]; for (uint16 i = 0; i < 15; ++i) curPalette[i] = darkBluePalette[i]; curPalette[15] = D09_RGB_WHITE; _displayMan->startEndFadeToPalette(curPalette); _displayMan->updateScreen(); if (waitBeforeDrawingRestart) delay(300); if (_restartGameAllowed) { _displayMan->_useByteBoxCoordinates = false; _displayMan->fillScreenBox(restartOuterBox, k12_ColorDarkestGray); _displayMan->fillScreenBox(restartInnerBox, k0_ColorBlack); switch (getGameLanguage()) { // localized default: case Common::EN_ANY: _textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RESTART THIS GAME"); break; case Common::DE_DEU: _textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "DIESES SPIEL NEU STARTEN"); break; case Common::FR_FRA: _textMan->printToLogicalScreen(110, 154, k4_ColorCyan, k0_ColorBlack, "RECOMMENCER CE JEU"); break; } curPalette[1] = D03_RGB_PINK; curPalette[4] = D09_RGB_WHITE; _eventMan->_primaryMouseInput = _eventMan->_primaryMouseInputRestartGame; _eventMan->discardAllInput(); _eventMan->hideMouse(); _displayMan->startEndFadeToPalette(curPalette); for (int16 verticalBlankCount = 900; --verticalBlankCount && !_restartGameRequest; delay(1)) _eventMan->processCommandQueue(); _eventMan->showMouse(); if (_restartGameRequest) { _displayMan->startEndFadeToPalette(darkBluePalette); _displayMan->fillScreen(k0_ColorBlack); _displayMan->startEndFadeToPalette(_displayMan->_palDungeonView[0]); _newGameFl = k0_modeLoadSavedGame; if (loadgame(1) != kM1_LoadgameFailure) { startGame(); _restartGameRequest = false; _eventMan->hideMouse(); _eventMan->discardAllInput(); return; } } } _displayMan->startEndFadeToPalette(darkBluePalette); } Box box(0, 319, 0, 199); _displayMan->blitToScreen(_displayMan->getNativeBitmapOrGraphic(k5_creditsGraphicIndice), &box, k160_byteWidthScreen, kM1_ColorNoTransparency, k200_heightScreen); _displayMan->startEndFadeToPalette(_displayMan->_palCredits); _eventMan->waitForMouseOrKeyActivity(); if (_engineShouldQuit) return; if (_restartGameAllowed && doNotDrawCreditsOnly) { waitBeforeDrawingRestart = false; _displayMan->startEndFadeToPalette(darkBluePalette); goto T0444017; } _engineShouldQuit = true; return; }
void main() { int gdriver = DETECT, gmode; initgraph(&gdriver, &gmode, "\\tc\\bgi"); cleardevice(); king("ch1"); int Mstatus = initmouse(); int button,m,n,slot; settextstyle(2,0,4); outtextxy(230,130,"LOADING"); if(Mstatus == 0 ) outtextxy(50,50, "Mouse Support Not Available"); while(!kbhit()) { showmouseptr(); getmousepos(&button,&m,&n); if(m>245 && m<325 && n>320 && n<332) { setcolor(RED); outtextxy(250,320,"BACK"); } else { setcolor(WHITE); outtextxy(250,320,"BACK"); if(m>215 && m<300 && n>164 && n<177) { setcolor(RED); outtextxy(220,165,"Slot 1"); } else { setcolor(WHITE); outtextxy(220,165,"Slot 1"); if(m>215 && m<300 && n>179 && n<192) { setcolor(RED); outtextxy(220,180,"Slot 2"); } else { setcolor(WHITE); outtextxy(220,180,"Slot 2"); if(m>215 && m<300 && n>194 && n<207) { setcolor(RED); outtextxy(220,195,"Slot 3"); } else { setcolor(WHITE); outtextxy(220,195,"Slot 3"); if(m>215 && m<300 && n>209 && n<222) { setcolor(RED); outtextxy(220,210,"Slot 4"); } else { setcolor(WHITE); outtextxy(220,210,"Slot 4"); if(m>215 && m<300 && n>224 && n<237) { setcolor(RED); outtextxy(220,225,"Slot 5"); } else { setcolor(WHITE); outtextxy(220,225,"Slot 5"); if(m>215 && m<300 && n>239 && n<252) { setcolor(RED); outtextxy(220,240,"Slot 6"); } else { setcolor(WHITE); outtextxy(220,240,"Slot 6"); if(m>215 && m<300 && n>254 && n<267) { setcolor(RED); outtextxy(220,255,"Slot 7"); } else { setcolor(WHITE); outtextxy(220,255,"Slot 7"); if(m>215 && m<300 && n>269 && n<282) { setcolor(RED); outtextxy(220,270,"Slot 8"); } else { setcolor(WHITE); outtextxy(220,270,"Slot 8"); if(m>215 && m<300 && n>284 && n<297) { setcolor(RED); outtextxy(220,285,"Slot 9"); } else { setcolor(WHITE); outtextxy(220,285,"Slot 9"); if(m>215 && m<300 && n>299 && n<312) { setcolor(RED); outtextxy(220,300,"Slot 10"); } else { setcolor(WHITE); outtextxy(220,300,"Slot 10"); }}}}}}}}}}} if(button == 1) { if(m>245 && m<325 && n>320 && n<332) { hidemouseptr(); video(450,150); // spawnl(P_WAIT,"g:\\exe\\menu1.exe", NULL); // back to main menu break; } if(m>215 && m<300 && n>164 && n<177) { hidemouseptr(); video(450,150); slot=1; loadgame(slot); } if(m>215 && m<300 && n>179 && n<192) { hidemouseptr(); video(450,150); slot=2; loadgame(slot); } if(m>215 && m<300 && n>194 && n<207) { hidemouseptr(); video(450,150); slot=3; loadgame(slot); } if(m>215 && m<300 && n>209 && n<222) { hidemouseptr(); video(450,150); slot=4; loadgame(slot); } if(m>215 && m<300 && n>224 && n<237) { hidemouseptr(); video(450,150); slot=5; loadgame(slot);} if(m>215 && m<300 && n>239 && n<252) {hidemouseptr(); video(450,150); slot=6; loadgame(slot);} if(m>215 && m<300 && n>254 && n<267) {hidemouseptr(); video(450,150); slot=7; loadgame(slot);} if(m>215 && m<300 && n>269 && n<282) {hidemouseptr(); video(450,150); slot=8; loadgame(slot);} if(m>215 && m<300 && n>284 && n<297) {hidemouseptr(); video(450,150); slot=9; loadgame(slot);} if(m>215 && m<300 && n>299 && n<312) {hidemouseptr(); video(450,150); slot=10; loadgame(slot);}}}}
void main() { tolog("main start\n"); void keytogame(), keytoinv(), map(), notify(), sounds_print(), loadgame(), eraseanimals(), *mech(); int ch; pthread_t mechthread; printf("\nEyecube\nCopyright (C) 2011 Alexander Kromm\nThis program comes with ABSOLUTELY NO WARRANTY.\nThis is free software, and you are welcome to redistribute it\nunder certain conditions; see README for details.\n\n"); (void)set_escdelay(10); // signal='w'; (void)initscr(); (void)start_color(); // (void)cbreak(); (void)raw(); (void)noecho(); (void)keypad(stdscr, TRUE); // setlocale(LC_ALL, "ru_Ru.utf8"); curs_set(0); //make cursor invisible (void)init_pair(WHITE_BLUE, COLOR_WHITE, COLOR_BLUE ); //player, sky (void)init_pair(BLACK_GREEN, COLOR_BLACK, COLOR_GREEN ); //grass, dwarf (void)init_pair(BLACK_WHITE, COLOR_BLACK, COLOR_WHITE ); //stone, skin (void)init_pair(RED_YELLOW, COLOR_RED, COLOR_YELLOW); //sun, fire1 (void)init_pair(RED_WHITE, COLOR_RED, COLOR_WHITE ); //chiken (void)init_pair(WHITE_BLACK, COLOR_WHITE, COLOR_BLACK ); //?, heap (void)init_pair(YELLOW_RED, COLOR_YELLOW, COLOR_RED ); //fire2 (void)init_pair(BLACK_RED, COLOR_BLACK, COLOR_RED ); //pointer (void)init_pair(BLACK_YELLOW, COLOR_BLACK, COLOR_YELLOW); //wood (void)init_pair(BLUE_YELLOW, COLOR_BLUE, COLOR_YELLOW); //clock (void)init_pair(WHITE_CYAN, COLOR_WHITE, COLOR_CYAN ); //noon sky (void)init_pair(BLACK_BLUE, COLOR_BLACK, COLOR_BLUE ); //raven (void)init_pair(BLACK_CYAN, COLOR_BLACK, COLOR_CYAN ); //raven (void)init_pair(RED_BLUE, COLOR_RED, COLOR_BLUE ); //bird (void)init_pair(RED_CYAN, COLOR_RED, COLOR_CYAN ); //bird (void)init_pair(RED_BLACK, COLOR_RED, COLOR_BLACK ); //bird world= newwin(23, 44, 0, 0); pocketwin= newwin(1, 44, 23, 0); textwin= newwin(5, 36, 24, 8); sound_window=newwin(5, 8, 24, 0); (void)refresh(); loadgame(); //start parallel thread (void)pthread_create(&mechthread, NULL, mech, NULL); map(); sounds_print(); notify("Game started.", 0); //this is the game itself while ((ch=getch())!=(int)'Q') { switch (view) { case VIEW_SURFACE: case VIEW_FLOOR: case VIEW_HEAD: case VIEW_SKY: case VIEW_FRONT: keytogame(ch); break; case VIEW_MENU: key_to_menu(ch); break; default: keytoinv(ch); break; } // sleep(1); usleep(10000); } //stop parallel thread eraseanimals(1); (void)pthread_cancel(mechthread); (void)delwin(world ); (void)delwin(textwin ); (void)delwin(pocketwin); (void)endwin(); tolog("main finish\n"); }
void on_load1_activate (GtkMenuItem *menuitem, gpointer user_data) { loadgame(); }
int CMD_ordersdue(int argc, char** argv) { FILE* gmnote; FILE* mof_fp; char* gmbody; game* aGame; player* aplayer; envelope* env; char* missing_orders_file = NULL; char* orders_dir; char* orders_file; int result; int msg_count = 0; result = EXIT_FAILURE; if (argc < 3) { usage(); } else if ((aGame = loadgame(argv[2], LG_CURRENT_TURN)) != NULL) { loadNGConfig( aGame ); gmbody = createString("%s/orders_due_%s", tempdir, aGame->name); gmnote = fopen(gmbody, "w"); orders_dir = createString("%s/orders/%s/", galaxynghome, aGame->name); for (aplayer = aGame->players; aplayer; aplayer = aplayer->next) { if (aplayer->flags & F_DEAD) continue; orders_file = createString("%s/%s.%d", orders_dir, aplayer->name, aGame->turn+1); if (access(orders_file, R_OK) == -1) { free(orders_file); orders_file = createString("%s/%s_final.%d", orders_dir, aplayer->name, aGame->turn+1); if (access(orders_file, R_OK) == -1) { env = createEnvelope(); env->to = strdup(aplayer->addr); env->from = strdup(aGame->serverOptions.SERVERemail); env->subject = createString("Turn %d of %s is about to run", aGame->turn+1, argv[2]); setHeader(env, MAILHEADER_REPLYTO, aGame->serverOptions.ReplyTo); env->from_name = strdup(aGame->serverOptions.SERVERname); env->from_address = strdup(aGame->serverOptions.SERVERemail); if (msg_count == 0) { fprintf(gmnote, "The following players have not yet " "submitted orders for turn %d of %s\n", aGame->turn+1, aGame->name); missing_orders_file = createString("%s/data/%s/missing_orders.%d", galaxynghome, aGame->name, aGame->turn+1); mof_fp = fopen(missing_orders_file, "w"); fprintf(mof_fp, "Your orders for turn %d for %s have not been " "received.\nOrders are due in %s hours. " "Please send them now.\n" "If you don't plan on sending in orders, please submit a\n" "Quit order (\"Q <racename>\") as it will stop these\n" "annoying emails to you and could help speed up the game\n" "for the other players. Thank you.\n", aGame->turn+1, aGame->name, aGame->serverOptions.due); fclose(mof_fp); } fprintf(gmnote, "%s has not turned in orders.\n", aplayer->name); result |= eMail(aGame, env, missing_orders_file); destroyEnvelope(env); msg_count++; } free(orders_file); } } free(orders_dir); } else { fprintf(stderr, "Cannot open game %s\n", argv[2]); } if (missing_orders_file) { unlink(missing_orders_file); free(missing_orders_file); } if (msg_count) { fclose(gmnote); env = createEnvelope(); env->to = strdup(aGame->serverOptions.GMemail); env->from = strdup(aGame->serverOptions.SERVERemail); env->subject = createString("Turn %d of %s is about to run", aGame->turn+1, aGame->name); setHeader(env, MAILHEADER_REPLYTO, aGame->serverOptions.ReplyTo); env->from_name = strdup(aGame->serverOptions.SERVERname); env->from_address = strdup(aGame->serverOptions.SERVERemail); result |= eMail(aGame, env, gmbody); destroyEnvelope(env); } return result; }
void IOManager::update(InputManager *IManager, Cursor* cursor, Player* player, int &game_state, float dt) { if(IManager->push_button(DIK_S)) { int temp = 0; if(!IManager->check_button_down(DIK_S)) { IManager->set_button(DIK_S, true); ++iterator; } }else{ IManager->set_button(DIK_S, false); } if(IManager->push_button(DIK_BACKSPACE)) { if(!IManager->check_button_down(DIK_BACKSPACE)) { IManager->set_button(DIK_BACKSPACE, true); game_state = MENU; } }else IManager->set_button(DIK_BACKSPACE, false); if(IManager->push_button(DIK_RSHIFT)) { if(!IManager->check_button_down(DIK_RSHIFT)) { IManager->set_button(DIK_RSHIFT, true); game_state = MENU; } }else IManager->set_button(DIK_RSHIFT, false); if(IManager->push_button(DIK_7)){ if(!IManager->check_button_down(DIK_7)){ IManager->set_button(DIK_7, true); m_gameSave[2][0] = 1; m_gameSave[2][2] = 14; } }else IManager->set_button(DIK_7, false); for(auto &buttons: saveloadButtons) { if(buttons.isOn(cursor->cursorPos.x, cursor->cursorPos.y, 3)) { buttons.setColor(D3DCOLOR_ARGB(255,255,255,0)); buttons.setHighlight(true); } else { buttons.setColor(D3DCOLOR_ARGB(255,255,255,255)); buttons.setHighlight(false); } } /////////////////////////////////////////////// // INFO: Save / Load game controls int selection = -1; if(IManager->check_mouse_button(LEFT_MOUSE_BUTTON)){ //for(auto &buttons: saveloadButtons){ for(int i = 0; i < SAVEMENUBUTTONCOUNT; ++i){ if(saveloadButtons[i].isOn(cursor->cursorPos.x, cursor->cursorPos.y, 3)){ selection = i; break; } } } switch(selection){ case -1: // Did not select a button break; case 0: // Save 1 //break; case 1: // Save 2 //break; case 2: // Save 3 if(game_state == LOAD){ loadgame(selection, player, 0); game_state = OVERWORLD; } else if (game_state == SAVE) savegame(selection, player, 0); break; case 3: // Main Menu Button game_state = MENU; break; }; }
void DreamGenContext::checkcoords(const RectWithCallback *rectWithCallbacks) { if (data.byte(kNewlocation) != 0xff) return; const RectWithCallback *rectWithCallback = rectWithCallbacks; while (rectWithCallback->xMin() != 0xffff) { if (rectWithCallback->contains(data.word(kMousex), data.word(kMousey))) { uint16 callback = rectWithCallback->callback(); // common if(callback == addr_blank) blank(); else if(callback == addr_getbackfromob) getbackfromob(); else if(callback == addr_incryanpage) incryanpage(); else if(callback == addr_getback1) getback1(); else if(callback == addr_quitkey) quitkey(); else if(callback == addr_dosreturn) dosreturn(); else if(callback == addr_getbacktoops) getbacktoops(); else if(callback == addr_selectslot) selectslot(); // examlist else if(callback == addr_useobject) useobject(); else if(callback == addr_selectopenob) selectopenob(); else if(callback == addr_setpickup) setpickup(); else if(callback == addr_examinventory) examinventory(); // invlist1 else if(callback == addr_dropobject) dropobject(); else if(callback == addr_useopened) useopened(); else if(callback == addr_setpickup) setpickup(); else if(callback == addr_intoinv) intoinv(); // withlist1 else if(callback == addr_selectob) selectob(); // talklist else if(callback == addr_moretalk) moretalk(); // quitlist // destlist else if(callback == addr_nextdest) nextdest(); else if(callback == addr_lastdest) lastdest(); else if(callback == addr_lookatplace) lookatplace(); else if(callback == addr_destselect) destselect(); // keypadlist else if(callback == addr_buttonone) buttonone(); else if(callback == addr_buttontwo) buttontwo(); else if(callback == addr_buttonthree) buttonthree(); else if(callback == addr_buttonfour) buttonfour(); else if(callback == addr_buttonfive) buttonfive(); else if(callback == addr_buttonsix) buttonsix(); else if(callback == addr_buttonseven) buttonseven(); else if(callback == addr_buttoneight) buttoneight(); else if(callback == addr_buttonnine) buttonnine(); else if(callback == addr_buttonnought) buttonnought(); else if(callback == addr_buttonenter) buttonenter(); // menulist // folderlist else if(callback == addr_nextfolder) nextfolder(); else if(callback == addr_lastfolder) lastfolder(); // symbollist else if(callback == addr_quitsymbol) quitsymbol(); else if(callback == addr_settopleft) settopleft(); else if(callback == addr_settopright) settopright(); else if(callback == addr_setbotleft) setbotleft(); else if(callback == addr_setbotright) setbotright(); // diarylist else if(callback == addr_diarykeyn) diarykeyn(); else if(callback == addr_diarykeyp) diarykeyp(); else if(callback == addr_quitkey) quitkey(); // opslist else if(callback == addr_getbackfromops) getbackfromops(); else if(callback == addr_discops) discops(); // discopslist else if(callback == addr_loadgame) loadgame(); else if(callback == addr_savegame) savegame(); // mainlist, mainlist2 else if(callback == addr_look) look(); else if(callback == addr_inventory) inventory(); else if(callback == addr_zoomonoff) zoomonoff(); else if(callback == addr_saveload) saveload(); else if(callback == addr_madmanrun) madmanrun(); else if(callback == addr_identifyob) identifyob(); // decidelist else if(callback == addr_newgame) newgame(); else if(callback == addr_loadold) loadold(); // loadlist else if(callback == addr_actualload) actualload(); // savelist else if(callback == addr_actualsave) actualsave(); else { debug("__dispatch_call remaining in checkcoords! %d", (int)callback); __dispatch_call(callback); } return; } ++rectWithCallback; } }
/* Function Definitions */ int mainoptions() { //Will draw five buttons each having the following fucntions //1. New Game //2. Load Game //3. Rules //4. About //5. Quit button button[5]; int xmax = getmaxx(); int ymax = getmaxy(); char *text; int i; unsigned size; mouse_data mouse; cleardevice(); hide_mouse(); setfillstyle(SOLID_FILL, LIGHTGRAY); bar(0,0,xmax,ymax); //Draw the five buttons and store their info for(i = 0; i <= 4; i++) { //Mention the coordinates of the buttons button[i].coords[0][0] = xmax / 2 - 100; // Left button[i].coords[0][1] = (i * 30) + 100; // Top button[i].coords[1][0] = xmax / 2 + 100; // Right button[i].coords[1][1] = ((i + 1) * 30) + 99; // Bottom //Dynamically allocate memory for images of up and down buttons size = imagesize(button[i].coords[0][0], button[i].coords[0][1], button[i].coords[1][0], button[i].coords[1][1]); button[i].up = (int *)malloc(size); if(!button[i].up){ cout << "Error.."; getch(); exit(0); } button[i].down = (int *)malloc(size); if(!button[i].down){ cout << "Error.."; getch(); exit(0); } //Put the text on button's face switch (i) { case 0: text = "Start New Game"; break; case 1: text = "Load Game"; break; case 2: text = "The Rules"; break; case 3: text = "About Ludo Master 2002"; break; case 4: text = "Quit"; break; } //Draw button and store info draw_button(button[i].coords[0][0], button[i].coords[0][1], button[i].coords[1][0], button[i].coords[1][1], LIGHTBLUE, LIGHTCYAN, BLUE, WHITE, text, button[i].up,button[i].down); } show_mouse(); //Wait for user's response through mouse do { //When mouse button is pressed see if it is pressed on a button, if yes then suprress that button read_mouse(&mouse); if (button_press(LEFT_BUTTON, &mouse)) { // See which button user has pressed for(int i = 0; i <= 4; i++) { if ( mouse.x >= button[i].coords[0][0] && mouse.x <= button[i].coords[1][0] && mouse.y >= button[i].coords[0][1] && mouse.y <= button[i].coords[1][1]) { hide_mouse(); putimage(button[i].coords[0][0], button[i].coords[0][1], button[i].down, 0); show_mouse(); delay(100); hide_mouse(); putimage(button[i].coords[0][0], button[i].coords[0][1], button[i].up , 0); show_mouse(); //Delete the memory allocated to buttons' images for(int j = 0; j <= 4; j++) { free( (void*) button[j].up); free( (void*) button[j].down); } //Actions for each button user may click on switch (i) { case 0: // Start new game new_game_vars(); return gameoptions(); break; case 1: // Load game new_game_vars(); return loadgame(); break; case 2: // Rules of Ludo return 0; break; case 3: // About the author showlogo(); return 0; break; case 4: // Quit exit(1); break; } } } } } while(1); //Infinite loop }
static void mainmenu(void) { int menuresult[1]; int n = 1, logoheight, i; const char *const *copybanner = nh_get_copyright_banner(); const char **nhlogo; char verstr[32]; nh_bool first = TRUE; snprintf(verstr, ARRAY_SIZE(verstr), "Version %d.%d.%d", VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL); #if defined(NETCLIENT) if (ui_flags.connection_only) { netgame(); return; } #endif load_keymap(); /* netgame() assumes the keymap isn't loaded */ while (n >= 0) { if (COLS >= 100) { nhlogo = nhlogo_large; logoheight = sizeof (nhlogo_large) / sizeof (nhlogo_large[0]); } else { nhlogo = nhlogo_small; logoheight = sizeof (nhlogo_small) / sizeof (nhlogo_small[0]); } wclear(basewin); wattron(basewin, A_BOLD | COLOR_PAIR(4)); for (i = 0; i < logoheight; i++) { wmove(basewin, i, (COLS - strlen(nhlogo[0])) / 2); if (nhlogo[i]) waddstr(basewin, nhlogo[i]); } wattroff(basewin, A_BOLD | COLOR_PAIR(4)); mvwaddstr(basewin, LINES - 3, 0, copybanner[0]); mvwaddstr(basewin, LINES - 2, 0, copybanner[1]); mvwaddstr(basewin, LINES - 1, 0, copybanner[2]); mvwaddstr(basewin, LINES - 4, COLS - strlen(verstr), verstr); wnoutrefresh(basewin); if (first) { network_motd(); first = FALSE; } menuresult[0] = EXITGAME; /* default action */ if (!override_hackdir) curses_display_menu_core( STATIC_MENULIST(mainmenu_items), NULL, PICK_ONE, menuresult, curses_menu_callback, 0, logoheight - 1, COLS, LINES - 3, FALSE, NULL, FALSE); else curses_display_menu_core( STATIC_MENULIST(mainmenu_items_noclient), NULL, PICK_ONE, menuresult, curses_menu_callback, 0, logoheight - 1, COLS, LINES - 3, FALSE, NULL, FALSE); if (*menuresult == CURSES_MENU_CANCELLED && !ui_flags.done_hup) continue; switch (menuresult[0]) { case NEWGAME: rungame(FALSE); break; case LOAD: loadgame(); break; case REPLAY: replay(); break; case OPTIONS: display_options(TRUE); break; #if defined(NETCLIENT) case NETWORK: free_keymap(); /* don't use the local keymap for server play */ netgame(); load_keymap(); break; #endif case TOPTEN: show_topten(NULL, -1, FALSE, FALSE); break; case EXITGAME: case CURSES_MENU_CANCELLED: /* in case of hangup */ n = -1; /* simulate menu cancel */ break; } } free_keymap(); }
void iDraw() { iClear(); switch(flag) { case 0:frontpage(); break; case 1:if(win!=1 && timec!=1 && end==0) { roadsidedraw(); roaddraw(); roadlinedraw(); roadlinedraw_c(); mycarmove(); mycarmove_c(); traffic_rand(); winshow(); if(flag14<=3) { mark_delay(); track_col(); mark_light(); } else { cardamage(); showrace(); kilometershow(); timeshow(); } } if(collision==1500||busted==1||timec==1) { check_high(); } if(mark==1){ iShowBMP(0,0,"imagess//LOAD1.bmp"); mark=0; } //if(flag8==2) // reinitialize(); /* if(flag2==1&&busted==0) { call_police(); }*/ break; case 2:optionshow(); break; case 3:showhighscore(); break; case 4:helppage(); break; case 5:showcredit(); break; case 6:exit(0); break; case 8:loadgame(); break; } }
Common::Error ToltecsEngine::loadGameState(int slot) { const char *fileName = getSavegameFilename(slot); loadgame(fileName); return Common::kNoError; }
Common::Error NeverhoodEngine::loadGameState(int slot) { const char *fileName = getSavegameFilename(slot); if (!loadgame(fileName)) return Common::kReadingFailed; return Common::kNoError; }
int main(int argc, char **argv) { struct hist_record rec; char *line; game initgame; bool localdat = false; char cwd_buf[1024]; unsigned int (*bcounts)[3]; int ca[2]; date current = {0, 0, 0}; int arg; int rc; for (arg = 1; arg < argc; arg++) { if (!strcmp(argv[arg], "--localdat")) { localdat=true; } else { fprintf(stderr, "Unrecognised argument '%s'\n", argv[arg]); return 5; } } if(!(cwd=getcwd(cwd_buf, 1024))) { perror("getcwd"); return 5; } fprintf(stderr, "Loading data files...\n"); #ifndef WINDOWS if(chdir(localdat?cwd:DATIDIR)) { perror("Failed to enter data dir: chdir"); if(!localdat) fprintf(stderr, "(Maybe try with --localdat, or make install)\n"); return 5; } #endif rc = load_data(); if (rc) return rc; bcounts = calloc(ntypes, sizeof(*bcounts)); if (!bcounts) { perror("calloc"); return 5; } rc = set_init_state(&initgame); if (rc) return rc; fprintf(stderr, "Data files loaded\n"); while(!feof(stdin)) { line = fgetl(stdin); if (!line) { fprintf(stderr, "Unexpected EOF\n"); return 3; } if (!strncmp(line, "History:", 8)) { free(line); break; } } while(!feof(stdin)) { line = fgetl(stdin); if (!line) break; rc = parse_event(&rec, line); if (rc) { fprintf(stderr, "Error %d in line: %s\n", rc, line); free(line); return rc; } free(line); if (rec.type == HT_INIT) { char savbuf[80]; snprintf(savbuf, 80, "save/%s", rec.init); rc = loadgame(savbuf, &initgame); if (rc) { fprintf(stderr, "Error %d loading INITgame '%s'\n", rc, savbuf); return 6; } for (unsigned int i = 0; i < initgame.nbombers; i++) bcounts[initgame.bombers[i].type][0]++; ca[0] = initgame.cshr; ca[1] = initgame.cash; } else if (rec.type == HT_AC) { if (rec.ac.type == AE_CT) { if (!rec.ac.fighter) { bcounts[rec.ac.ac_type][0]++; bcounts[rec.ac.ac_type][1]++; } } else if (rec.ac.type == AE_CROB) { if (!rec.ac.fighter) { bcounts[rec.ac.ac_type][0]--; bcounts[rec.ac.ac_type][2]++; } } } else if (rec.type == HT_MISC) { if (rec.misc.type == ME_CASH) { ca[0] = rec.misc.cash.delta; ca[1] = rec.misc.cash.current; } } if (diffdate(rec.date, current)) write_counts(current = rec.date, bcounts, ca); } return 0; }