void AdlEngine_v2::checkTextOverflow(char c) { if (c != APPLECHAR('\r')) return; ++_linesPrinted; if (_linesPrinted < 4) return; _linesPrinted = 0; _display->updateTextScreen(); bell(); while (true) { char key = inputKey(false); if (shouldQuit()) return; if (key == APPLECHAR('\r')) break; bell(3); } }
void HiRes5Engine::runIntro() { insertDisk(2); StreamPtr stream(_disk->createReadStream(0x10, 0x0, 0x00, 31)); _display->setMode(DISPLAY_MODE_HIRES); _display->loadFrameBuffer(*stream); _display->updateHiResScreen(); inputKey(); _display->home(); _display->setMode(DISPLAY_MODE_TEXT); stream.reset(_disk->createReadStream(0x03, 0xc, 0x34, 1)); Common::String menu(readString(*stream)); while (!g_engine->shouldQuit()) { _display->home(); _display->printString(menu); Common::String cmd(inputString()); // We ignore the backup and format menu options if (!cmd.empty() && cmd[0] == APPLECHAR('1')) break; }; }
/*============================================================================== * POLL */ void inputPoll() { SDL_Event event; memset(&event, 0, sizeof(event)); while(SDL_PollEvent(&event)) switch(event.type) { case SDL_KEYDOWN: inputKey(event.key.keysym.sym, event.key.keysym.unicode); break; case SDL_MOUSEMOTION: inputMouse(0, 0); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: inputMouse(event.button.button, event.button.state); break; case SDL_QUIT: exit(0); break; case SDL_VIDEORESIZE: break; default: break; } }
int CGameClient::PackInput() { int updown = 0, sides = 0; int button; if(inputKey('W')) updown -= 1; if(inputKey('S')) updown += 1; if(inputKey('A')) sides += 1; if(inputKey('D')) sides -= 1; mouse_x = inputGetMouseX()/2; mouse_y = -inputGetMouseY()/2; button = inputGetMouseButton(0); netPackInt(updown); netPackInt(sides); netPackInt(mouse_x); netPackInt(mouse_y); netPackInt(button); return 1; }
int tetrixStateLogo::updateScene(void) { inputKey(); if(!m_logoChecker) { m_referTetrix->RENDER showLogo(); m_logoChecker = true; } if(!m_exampleChecker) { m_referTetrix->RENDER exampleBlock(); m_exampleChecker = true; } else if(m_referTetrix->gameTimer(RESET_EXAMPLE_TIMER)) { m_exampleChecker = false; } return m_returnState; }
/**************************************************************************** Desc: Populate a vector's components from the key part of an index key. ****************************************************************************/ RCODE XFLAPI F_DataVector::inputKey( IF_Db * ifpDb, FLMUINT uiIndexNum, const FLMBYTE * pucKey, FLMUINT uiKeyLen) { RCODE rc = NE_XFLM_OK; IXD * pIxd; if (RC_BAD( rc = ((F_Db *)ifpDb)->m_pDict->getIndex( uiIndexNum, NULL, &pIxd, TRUE))) { goto Exit; } if (RC_BAD( rc = inputKey( pIxd, pucKey, uiKeyLen))) { goto Exit; } Exit: return( rc); }
void HiRes1Engine::runIntro() const { StreamPtr stream(_files->createReadStream(IDS_HR1_EXE_0)); stream->seek(IDI_HR1_OFS_LOGO_0); _display->setMode(DISPLAY_MODE_HIRES); _display->loadFrameBuffer(*stream); _display->updateHiResScreen(); delay(4000); if (shouldQuit()) return; _display->setMode(DISPLAY_MODE_TEXT); StreamPtr basic(_files->createReadStream(IDS_HR1_LOADER)); Common::String str; str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_0, '"'); _display->printAsciiString(str + '\r'); str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_1, '"'); _display->printAsciiString(str + "\r\r"); str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_2, '"'); _display->printAsciiString(str + "\r\r"); str = readStringAt(*basic, IDI_HR1_OFS_PD_TEXT_3, '"'); _display->printAsciiString(str + '\r'); inputKey(); if (g_engine->shouldQuit()) return; _display->setMode(DISPLAY_MODE_MIXED); str = readStringAt(*stream, IDI_HR1_OFS_GAME_OR_HELP); bool instructions = false; while (1) { _display->printString(str); Common::String s = inputString(); if (g_engine->shouldQuit()) break; if (s.empty()) continue; if (s[0] == APPLECHAR('I')) { instructions = true; break; } else if (s[0] == APPLECHAR('G')) { break; } }; if (instructions) { _display->setMode(DISPLAY_MODE_TEXT); stream->seek(IDI_HR1_OFS_INTRO_TEXT); const uint pages[] = { 6, 6, 4, 5, 8, 7, 0 }; uint page = 0; while (pages[page] != 0) { _display->home(); uint count = pages[page++]; for (uint i = 0; i < count; ++i) { str = readString(*stream); _display->printString(str); stream->seek(3, SEEK_CUR); } inputString(); if (g_engine->shouldQuit()) return; stream->seek(6, SEEK_CUR); } } _display->printAsciiString("\r"); _display->setMode(DISPLAY_MODE_MIXED); // Title screen shown during loading stream.reset(_files->createReadStream(IDS_HR1_EXE_1)); stream->seek(IDI_HR1_OFS_LOGO_1); _display->loadFrameBuffer(*stream); _display->updateHiResScreen(); delay(2000); }
// Displays an entry in a "doormud-style HLP" format file. This is a simple file format used to store a topic- // based help system. This function takes parameters as follows: // szFileName - Name of the help file // szTopic - Name of the help entry // szError - Error message to display if no such entry, or "none" if none. // bPartialMatch - true if "partial matches" allowed on topic name, if no full matches found. void displayHelp(char* szFileName, char* szTopic, char* szError, bool bPartialMatch) { ifstream ifsFile; short nColor = 7, nLineCount = 0; bool bFound = false, bNonstop = false, bSecondPass = false; char szLine[90], cKey; time_t timeout; if ( szFileName == NULL || szTopic == NULL || strlen(szTopic) < 1 ) return; ifsFile.open(szFileName); while ( ifsFile ) { ifsFile.getline(szLine, 90); // If partial-matches are enabled: If we don't find a full-match on first pass // of the hlp file, we go through it again looking for partial-matches. if ( !ifsFile && !bFound && !bSecondPass && bPartialMatch ) { ifsFile.clear(); ifsFile.seekg(0); bSecondPass = true; } if ( szLine == NULL ) continue; switch (szLine[0]) { case ';': if ( strlen(szLine) > 1 && strcmpi(&szLine[1], szTopic) == 0 ) bFound = true; if ( bSecondPass && strlen(szLine) > 1 && wordSearch(&szLine[1], szTopic) ) bFound = true; break; case '-': if ( bFound && strlen(szLine) == 1 ) return; if ( bFound && strlen(szLine) > 1 ) { if ( strcmpi(&szLine[1], szTopic) == 0 || szLine[1] == ' ' ) return; if ( bSecondPass && wordSearch(&szLine[1], szTopic) ) return; } break; //case ':': // return; case '$': if ( bFound && strlen(szLine) > 1 ) nColor = atoi(&szLine[1]); break; case '<': break; case ']': if ( strlen(szLine) > 1 && bFound ) local(&szLine[1], nColor, 0); break; default: if ( bFound ) { local(szLine, nColor); if ( ++nLineCount > 20 && !bNonstop) { local("(C)ontinue, (N)onstop, (Q)uit: ", WHITE, 0); timeout = time(NULL); cKey = 0; while ( cKey == 0 ) { cKey = inputKey(); checkCarrier(); checkTimeLeft(); inactiveCheck(timeout); Sleep(50); } local(" "); if ( cKey == 'n' || cKey == 'N' ) bNonstop = true; if ( cKey == 'q' || cKey == 'Q' || cKey == 'x' || cKey == 'X' || cKey == 's' || cKey == 'S' ) return; nLineCount = 0; } } break; } } if ( !bFound && strcmpi(szError, "none") != 0 ) local(szError); }
// Waits for input from the user, also printing new output when appropriate void getInput(char* szInput, short nMaxLength) { time_t timeout; char chKeyPressed; short nPosition = 0; static OutputData odMessage; // Decrease nMaxLength by one, since this function later doesn't count the null zero nMaxLength--; if(szInput == NULL || nMaxLength < 1) return; timeout=time(NULL); while (1) { // Check for lost carrier, time expired, etc. (Note that in the OpenDoors implementation, these functions // are blank, since OpenDoors does this type of checking automatically) checkCarrier(); checkTimeLeft(); inactiveCheck(timeout); chKeyPressed = 0; // While no input on screen, continue to display output for this node. while ( nPosition == 0 && chKeyPressed == 0 ) { checkCarrier(); checkTimeLeft(); inactiveCheck(timeout, 0); // Check for inter-node messages in synchronet if ( checkNodeMsg() ) fixStatline(); // Only respond to keyboard if there's a valid prompt on screen. if ( isValidPrompt() ) chKeyPressed = inputKey(); else Sleep(50); // Display all output waiting in mailslot, if any. if ( getOutput() ) fixStatline(); } // If no key pressed this cycle, try getting the key again. if ( chKeyPressed == 0 && isValidPrompt() ) chKeyPressed = inputKey(); // If a key was pressed if ( chKeyPressed != 0 ) { timeout=time(NULL); // Fix CR/LF problem, and ignore otherwise invalid characters if ( chKeyPressed == 10 || chKeyPressed < 0 ) continue; // Enter key hit: Add ending \0 to string and return. if(chKeyPressed == '\r' || chKeyPressed == '\n') { szInput[nPosition] = '\0'; newline(); bPromptOnScreen = false; return; } // At this point, user has definitely hit a non-enter key. If this is the // first key hit of a string, and there's no prompt on screen yet, display // it first before displaying the keystroke. if ( nPosition == 0 && !bPromptOnScreen ) fixStatline(); // Backspace key if( chKeyPressed == 8 && nPosition > 0 ) { backspace(1); --nPosition; continue; } // Any normal key if(chKeyPressed >= 32 && nPosition < nMaxLength && (unsigned char)chKeyPressed <= 127) { // Display the key and add it to the input buffer. printChar(chKeyPressed); szInput[nPosition++] = chKeyPressed; // If in hotkey mode, send the input immediately. if ( !bCommandMode ) { szInput[nPosition] = '\0'; newline(); bPromptOnScreen = false; return; } } } } }