void AccountsFunctions::createAccount() { enterName(); enterPassword(); cout << "Account successfully made!" << endl; saveAccounts(); loginMenu(); }
char * drawScore(int score, int isHighscore) { int i = 0; char * name = malloc(1); int curlength = 0; name[0] = '\0'; clear(); drawBox(60,20,50,10,0); char scoreStr[100]; sprintf(scoreStr, "%d", score); mvaddstr(22,80,"Game Over"); mvaddstr(24,77,"You Scored: "); mvaddstr(24,89,scoreStr); //do highscore stuff if (isHighscore == 1) { attron(COLOR_PAIR(1)); drawHighscoreTitle(16,4); mvaddstr(27,98,"Done"); drawBox(95,26,10,3,0); drawBox(75,26,20,3,0); mvaddstr(27,64,"Enter Name"); while (1) { usleep(90000); if (i == 0) { i = 1; } else { i = 0; } drawStarHighscore(i); refresh(); if (enterName(name,getch(),&curlength) == -1) { return name; } } attroff(COLOR_PAIR(1)); } else { mvaddstr(27,83,"Done"); drawBox(80,26,10,3,0); } while(getch() != '\n'){ } return NULL; }
/* -------------------------------------------------------------------- */ void newUser(char *initials, char *password) { label fullnm; char InitPw[80]; char Initials[80]; char passWord[80]; char *semicolon; int lines; int abort, good = 0; char firstime = 1; if (!CARRIER) return; unlisted = FALSE; /* default to [Y] for list in userlog for new users */ roomtell = TRUE; /* default to [Y] for display of room descriptions */ /* this only initializes log.buf, does not write it out */ if (newlog() == ERROR) return; logBuf.linesScreen = cfg.linesScreen; /* askTerm(); */ configure(TRUE); /* make sure new users configure reasonably */ lines = logBuf.linesScreen; tutorial("password.blb"); do { do { /* getNormStr("full name", fullnm, NAMESIZE, ECHO); */ enterName(cfg.enter_name, fullnm, NULL); if ( (personexists(fullnm) != ERROR ) || (strcmpi(fullnm, "Sysop") == SAMESTRING) || (strcmpi(fullnm, "Aide") == SAMESTRING) || !strlen(fullnm) ) { mPrintf("We already have a %s\n", fullnm); good = FALSE; } else (good = TRUE); } while(!good && CARRIER); if (!CARRIER) return; if (firstime) { strcpy(Initials, initials); } else { getNormStr("your initials", InitPw, 40, NO_ECHO); dospCR(); semicolon = strchr(InitPw, ';'); if( semicolon ) { normalizepw(InitPw, Initials, passWord); } else { strcpy(Initials, InitPw); } /* dont allow anything over 19 characters */ Initials[19] = '\0'; } do { if (firstime) { strcpy(passWord, password); } else if (!semicolon) { getNormStr("password", passWord, NAMESIZE, NO_ECHO); dospCR(); } firstime = FALSE; /* keeps from going in infinite loop */ semicolon = FALSE; if ( pwexists(passWord) != ERROR || strlen(passWord) < 2) { good = FALSE; mPrintf("\n Poor password\n "); } else good = TRUE; } while( !good && CARRIER ); displaypw(fullnm, Initials, passWord); abort = getYesNo("OK",2); if (abort == 2) return; /* check for Abort at (Y/N/A)[A]: */ } while ( (!abort) && CARRIER); if (CARRIER) { /* Moved from newlog() */ strcpy(logBuf.lbname, fullnm); strcpy(logBuf.lbin, Initials); strcpy(logBuf.lbpw, passWord); /* This stuff moved from newlog() time(&logBuf.calltime); setsysconfig(); /* * trap it */ sprintf( msgBuf->mbtext, "New user %s", logBuf.lbname); if (onConsole) strcat(msgBuf->mbtext, " (Console)"); trap(msgBuf->mbtext, T_LOGIN); loggedIn = TRUE; slideLTab(thisSlot); storeLog(); /* End of stuff moved from newlog() */ } logBuf.linesScreen = (uchar)lines; }
bool DrasculaEngine::saveLoadScreen() { char names[10][23]; char file[50]; char fileEpa[50]; int n, n2, num_sav = 0, y = 27; Common::InSaveFile *sav; clearRoom(); snprintf(fileEpa, 50, "%s.epa", _targetName.c_str()); if (!(sav = _saveFileMan->openForLoading(fileEpa))) { Common::OutSaveFile *epa; if (!(epa = _saveFileMan->openForSaving(fileEpa))) error("Can't open %s file", fileEpa); for (n = 0; n < NUM_SAVES; n++) epa->writeString("*\n"); epa->finalize(); delete epa; if (!(sav = _saveFileMan->openForLoading(fileEpa))) { error("Can't open %s file", fileEpa); } } for (n = 0; n < NUM_SAVES; n++) { strncpy(names[n], sav->readLine().c_str(), 23); names[n][22] = '\0'; // make sure the savegame name is 0-terminated } delete sav; loadPic("savescr.alg", bgSurface, HALF_PAL); color_abc(kColorLightGreen); select[0] = 0; _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, true); setCursor(kCursorCrosshair); while (!shouldQuit()) { y = 27; copyBackground(); for (n = 0; n < NUM_SAVES; n++) { print_abc(names[n], 116, y); y = y + 9; } print_abc(select, 117, 15); updateScreen(); y = 27; updateEvents(); if (leftMouseButton == 1) { delay(50); for (n = 0; n < NUM_SAVES; n++) { if (mouseX > 115 && mouseY > y + (9 * n) && mouseX < 115 + 175 && mouseY < y + 10 + (9 * n)) { strcpy(select, names[n]); if (strcmp(select, "*")) selectionMade = 1; else { enterName(); strcpy(names[n], select); if (selectionMade == 1) { snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1); saveGame(file); Common::OutSaveFile *tsav; if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { error("Can't open %s file", fileEpa); } for (n = 0; n < NUM_SAVES; n++) { tsav->writeString(names[n]); tsav->writeString("\n"); } tsav->finalize(); delete tsav; } } print_abc(select, 117, 15); y = 27; for (n2 = 0; n2 < NUM_SAVES; n2++) { print_abc(names[n2], 116, y); y = y + 9; } if (selectionMade == 1) { snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1); } num_sav = n; } } if (mouseX > 117 && mouseY > 15 && mouseX < 295 && mouseY < 24 && selectionMade == 1) { enterName(); strcpy(names[num_sav], select); print_abc(select, 117, 15); y = 27; for (n2 = 0; n2 < NUM_SAVES; n2++) { print_abc(names[n2], 116, y); y = y + 9; } if (selectionMade == 1) { snprintf(file, 50, "%s%02d", _targetName.c_str(), n + 1); saveGame(file); Common::OutSaveFile *tsav; if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { error("Can't open %s file", fileEpa); } for (n = 0; n < NUM_SAVES; n++) { tsav->writeString(names[n]); tsav->writeString("\n"); } tsav->finalize(); delete tsav; } } if (mouseX > 125 && mouseY > 123 && mouseX < 199 && mouseY < 149 && selectionMade == 1) { if (!loadGame(file)) { _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); return false; } break; } else if (mouseX > 208 && mouseY > 123 && mouseX < 282 && mouseY < 149 && selectionMade == 1) { saveGame(file); Common::OutSaveFile *tsav; if (!(tsav = _saveFileMan->openForSaving(fileEpa))) { error("Can't open %s file", fileEpa); } for (n = 0; n < NUM_SAVES; n++) { tsav->writeString(names[n]); tsav->writeString("\n"); } tsav->finalize(); delete tsav; } else if (mouseX > 168 && mouseY > 154 && mouseX < 242 && mouseY < 180) break; else if (selectionMade == 0) { print_abc("Please select a slot", 117, 15); } updateScreen(); delay(200); } y = 26; delay(5); } selectVerb(kVerbNone); clearRoom(); loadPic(roomNumber, bgSurface, HALF_PAL); selectionMade = 0; _system->setFeatureState(OSystem::kFeatureVirtualKeyboard, false); return true; }
void Engine::EngineLoop( ) { SDL_Event currentEvent; startTick = SDL_GetTicks( ); while( SDL_PollEvent( ¤tEvent ) ) { switch( currentEvent.type ) { case SDL_QUIT: engineState = Engine::exiting; break; case SDLK_ESCAPE: engineState = Engine::showingMenu; break; } if( currentEvent.type == SDL_KEYDOWN && engineState == Engine::playing ) { switch( currentEvent.key.keysym.sym ) { case SDLK_KP1: if( player.getBonus() ) player.setDirection( 5 ); else player.setDirection( 6 ); player.Move( ); break; case SDLK_KP2: if( player.getBonus() ) player.setDirection( 4 ); else player.setDirection( 3 ); player.Move( ); break; case SDLK_KP3: if( player.getBonus() ) player.setDirection( 6 ); else player.setDirection( 5 ); player.Move( ); break; case SDLK_KP4: if( player.getBonus() ) player.setDirection( 1 ); else player.setDirection( 2 ); player.Move( ); break; case SDLK_KP6: if( player.getBonus() ) player.setDirection( 2 ); else player.setDirection( 1 ); player.Move( ); break; case SDLK_KP7: if( player.getBonus() ) player.setDirection( 7 ); else player.setDirection( 8 ); player.Move( ); break; case SDLK_KP8: if( player.getBonus() ) player.setDirection( 3 ); else player.setDirection( 4 ); player.Move( ); break; case SDLK_KP9: if( player.getBonus() ) player.setDirection( 8 ); else player.setDirection( 7 ); player.Move( ); break; } } } switch( engineState ) { case Engine::playing: Game( ); break; case Engine::showingDeath: showDeath( ); break; case Engine::showingSplash: showSplash( ); break; case Engine::showingMenu: showMenu( ); break; case Engine::restart: Restart( ); break; case Engine::starting: Starting( ); break; case Engine::showingHighscore: showHighScore( ); break; case Engine::enteringName: enterName( ); break; } SDL_Flip( screen ); if( SDL_GetTicks( ) - startTick < 1000 / 30 ) { SDL_Delay( ( 1000 / 30 ) - (SDL_GetTicks() - startTick) ); } }
void AccountsFunctions::loginAccount() { enterName(); enterPassword(); //look if there is such account }