void RS_ActionDrawCircleInscribe::init(int status) { RS_PreviewActionInterface::init(status); if(status>=0) { RS_Snapper::suspend(); } clearLines(true); }
void RS_ActionDrawEllipseInscribe::trigger() { RS_PreviewActionInterface::trigger(); RS_Ellipse* ellipse=new RS_Ellipse(container, *eData); deletePreview(); container->addEntity(ellipse); // upd. undo list: if (document) { document->startUndoCycle(); document->addUndoable(ellipse); document->endUndoCycle(); } for(RS_Line*const p: lines) { if(!p) continue; p->setHighlighted(false); graphicView->drawEntity(p); } drawSnapper(); clearLines(false); setStatus(SetLine1); RS_DEBUG->print("RS_ActionDrawEllipse4Line::trigger():" " entity added: %d", ellipse->getId()); }
void RS_ActionDrawEllipseInscribe::mouseMoveEvent(QMouseEvent* e) { RS_DEBUG->print("RS_ActionDrawEllipse4Line::mouseMoveEvent begin"); if(getStatus() == SetLine4) { RS_Entity* en = catchEntity(e, RS2::EntityLine, RS2::ResolveAll); if(!en) return; if(!(en->isVisible() && en->rtti()== RS2::EntityLine)) return; for(auto p: lines){ if(en == p) return; //do not pull in the same line again } if(en->getParent() && en->getParent()->ignoredOnModification()){ return; } deletePreview(); clearLines(true); lines.push_back(static_cast<RS_Line*>(en)); if(preparePreview()) { lines.back()->setHighlighted(true); graphicView->drawEntity(lines.back()); RS_Ellipse* e=new RS_Ellipse(preview.get(), *eData); preview->addEntity(e); drawPreview(); } } RS_DEBUG->print("RS_ActionDrawEllipse4Line::mouseMoveEvent end"); }
void AgiEngine::clearPrompt() { int l; l = _game.lineUserInput; clearLines(l, l, _game.colorBg); flushLines(l, l); _gfx->doUpdate(); }
void RS_ActionDrawEllipseInscribe::mouseReleaseEvent(QMouseEvent* e) { // Proceed to next status if (e->button()==Qt::LeftButton) { if (!e) return; RS_Entity* en = catchEntity(e, RS2::EntityLine, RS2::ResolveAll); if(!en) return; if(!(en->isVisible() && en->rtti()== RS2::EntityLine)) return; for(int i=0;i<getStatus();i++) { if(en->getId() == lines[i]->getId()) return; //do not pull in the same line again } if(en->getParent()) { if ( en->getParent()->ignoredOnModification()) return; } clearLines(true); lines.push_back(static_cast<RS_Line*>(en)); switch (getStatus()) { case SetLine1: case SetLine2: case SetLine3: en->setHighlighted(true); graphicView->drawEntity(en); setStatus(getStatus()+1); break; case SetLine4: if( preparePreview()) { trigger(); } default: break; } } else if (e->button()==Qt::RightButton) { // Return to last status: if(getStatus()>0){ clearLines(true); lines.back()->setHighlighted(false); graphicView->drawEntity(lines.back()); lines.pop_back(); deletePreview(); } init(getStatus()-1); } }
void gameUpdate(){ if (!moveDown(&fallItem)){ if (addItemToMap(&fallItem)){ gameStatus = GAME_End; return; } clearLines(); nextToFall(); } }
void UberCalc::addToResultLine(QString newSym) { if (ui->resultLine->text()[0] == 'D') { ui->resultLine->clear(); } else if (ui->action->text() == "=") { clearLines(); } ui->resultLine->setText(ui->resultLine->text() + newSym); }
/** * Write the status line. */ void AgiEngine::writeStatus() { char x[64]; if (_debug.statusline) { printStatus("%3d(%03d) %3d,%3d(%3d,%3d) ", getvar(0), getvar(1), _game.viewTable[0].xPos, _game.viewTable[0].yPos, WIN_TO_PIC_X(_mouse.x), WIN_TO_PIC_Y(_mouse.y)); return; } if (!_game.statusLine) { clearLines(_game.lineStatus, _game.lineStatus, 0); flushLines(_game.lineStatus, _game.lineStatus); #if 0 // FIXME: Breaks wrist watch prompt in SQ2 // Clear the user input line as well when clearing the status line // Fixes bug #1893564 - AGI: Texts messed out in Naturette 1 clearLines(_game.lineUserInput, _game.lineUserInput, 0); flushLines(_game.lineUserInput, _game.lineUserInput); #endif return; } switch (getLanguage()) { case Common::RU_RUS: sprintf(x, " \x91\xe7\xa5\xe2: %i \xa8\xa7 %-3i", _game.vars[vScore], _game.vars[vMaxScore]); printStatus("%-17s \x87\xa2\xe3\xaa:%s", x, getflag(fSoundOn) ? "\xa2\xaa\xab " : "\xa2\xeb\xaa\xab"); break; default: sprintf(x, " Score:%i of %-3i", _game.vars[vScore], _game.vars[vMaxScore]); printStatus("%-17s Sound:%s ", x, getflag(fSoundOn) ? "on " : "off"); break; } }
void NeuesKontoDialog::clickAdd() /****************************************************************************** * Methode bereitet Eingabefelder fuer weitergabe an MainWindow1 auf *******************************************************************************/ { //ToDo: Fehleranalyse ... Einagbewerte checken... Konto *tempKonto = new Konto ( lineKontoName -> text(), lineKontoBeschreibung -> text(), lineBLZ -> text(), lineBankName -> text(), 0, //KontoTyp spinboxLimit -> value(), checkBeUnderLimit -> checkState() ); emit add ( tempKonto ); // tempKonto wird in ~MainWindow1 geloescht clearLines(); close(); }
void BootstrapModelPrivate::reload() { m_EditState = BootstrapModel::EditState::RELOADING; clearLines(); for(const QString& line : m_pAccount->hostname().split(';')) { const QStringList& fields = line.split(':'); if (line.size() && fields.size() && !(fields[0].isEmpty() && (fields.size()-1 && fields[1].isEmpty()))) { BootstrapModelPrivate::Lines* l = new BootstrapModelPrivate::Lines(); l->hostname = fields[0].trimmed(); l->port = fields.size()>1?fields[1].toInt():-1; //-1 == default q_ptr->beginInsertRows(QModelIndex(),m_lines.size(), m_lines.size()); m_lines << l; q_ptr->endInsertRows(); } } m_EditState = BootstrapModel::EditState::READY; }
void dropPiece() { DROP *d = (DROP*)dropData+useClip+1; int r = rotation%(d->rotations); PIECE *p = &(d->peice[r]); int i, x, y; bool keepFalling = true; while(keepFalling) { drop_y += 1; if(!checkIfValidPosition()) { keepFalling = false; } } drop_y -= 1; //that last step wasn't valid so undo //Add to grid for(i=0; i<4; i++) { BLOCK *b = &(p->blocks[i]); x = (drop_x + b->x); y = (drop_y + b->y); if(x >= 0 && y >= 0 && x < 10 && y < 16) { grid[x][y] = useClip+1; } } drop_x = DROP_START_X; drop_y = DROP_START_Y; useClip = nextPiece; nextPiece = pickNewPiece(); rotation = 0; fallTimer = 0; clearLines(); if(!checkIfValidPosition()) { //Game over mode = MODE_GAMEOVER; } }
/** * Print user input prompt. */ void AgiEngine::writePrompt() { int l, fg, bg, pos; int promptLength = strlen(agiSprintf(_game.strings[0])); if (!_game.inputEnabled || _game.inputMode != INPUT_NORMAL) return; l = _game.lineUserInput; fg = _game.colorFg; bg = _game.colorBg; pos = _game.cursorPos; debugC(4, kDebugLevelText, "erase line %d", l); clearLines(l, l, _game.colorBg); debugC(4, kDebugLevelText, "prompt = '%s'", agiSprintf(_game.strings[0])); printText(_game.strings[0], 0, 0, l, promptLength + 1, fg, bg); printText((char *)_game.inputBuffer, 0, promptLength, l, pos + 1, fg, bg); _gfx->printCharacter(pos + promptLength, l, _game.cursorChar, fg, bg); flushLines(l, l); _gfx->doUpdate(); }
void RS_ActionDrawCircleInscribe::trigger() { RS_PreviewActionInterface::trigger(); RS_Circle* circle=new RS_Circle(container, pPoints->cData); deletePreview(); container->addEntity(circle); // upd. undo list: if (document) { document->startUndoCycle(); document->addUndoable(circle); document->endUndoCycle(); } clearLines(false); setStatus(SetLine1); RS_DEBUG->print("RS_ActionDrawCircle4Line::trigger():" " entity added: %d", circle->getId()); }
void UberCalc::clearClicked() { clearLines(); fArgChosen = false; }
void AgiEngine::handleKeys(int key) { uint8 *p = NULL; int c = 0; static uint8 formattedEntry[40]; int l = _game.lineUserInput; int fg = _game.colorFg, bg = _game.colorBg; int promptLength = strlen(agiSprintf(_game.strings[0])); setvar(vWordNotFound, 0); debugC(3, kDebugLevelInput, "handling key: %02x", key); switch (key) { case KEY_ENTER: debugC(3, kDebugLevelInput, "KEY_ENTER"); _game.keypress = 0; // Remove all leading spaces for (p = _game.inputBuffer; *p && *p == 0x20; p++) ; // Copy to internal buffer for (; *p && c < 40-1; p++) { // Squash spaces if (*p == 0x20 && *(p + 1) == 0x20) { p++; continue; } formattedEntry[c++] = tolower(*p); } formattedEntry[c++] = 0; // Handle string only if it's not empty if (formattedEntry[0]) { strcpy((char *)_game.echoBuffer, (const char *)_game.inputBuffer); strcpy(_lastSentence, (const char *)formattedEntry); dictionaryWords(_lastSentence); } // Clear to start a new line _game.hasPrompt = 0; _game.inputBuffer[_game.cursorPos = 0] = 0; debugC(3, kDebugLevelInput | kDebugLevelText, "clear lines"); clearLines(l, l + 1, bg); flushLines(l, l + 1); #ifdef __DS__ DS::findWordCompletions((char *) _game.inputBuffer); #endif break; case KEY_ESCAPE: debugC(3, kDebugLevelInput, "KEY_ESCAPE"); newInputMode(INPUT_MENU); break; case KEY_BACKSPACE: // Ignore backspace at start of line if (_game.cursorPos == 0) break; // erase cursor _gfx->printCharacter(_game.cursorPos + promptLength, l, ' ', fg, bg); _game.inputBuffer[--_game.cursorPos] = 0; // Print cursor _gfx->printCharacter(_game.cursorPos + promptLength, l, _game.cursorChar, fg, bg); #ifdef __DS__ DS::findWordCompletions((char *) _game.inputBuffer); #endif break; default: // Ignore invalid keystrokes if (key < 0x20 || key > 0x7f) break; // Maximum input size reached if (_game.cursorPos >= getvar(vMaxInputChars)) break; _game.inputBuffer[_game.cursorPos++] = key; _game.inputBuffer[_game.cursorPos] = 0; #ifdef __DS__ DS::findWordCompletions((char *) _game.inputBuffer); #endif // echo _gfx->printCharacter(_game.cursorPos + promptLength - 1, l, _game.inputBuffer[_game.cursorPos - 1], fg, bg); // Print cursor _gfx->printCharacter(_game.cursorPos + promptLength, l, _game.cursorChar, fg, bg); break; } }
void RS_ActionDrawCircleInscribe::finish(bool updateTB){ clearLines(); RS_PreviewActionInterface::finish(updateTB); }
void BootstrapModelPrivate::clear() { clearLines(); q_ptr << BootstrapModel::EditAction::MODIFY; }
void main() { int dac_mode; float min_volts, max_volts; float phase_shift; int index_shift; int channel; int key; int wave; int i; int length; char display[128]; char tmpbuf[32]; // Initialize controller brdInit(); DispStr(1, 2, "DAC output voltage configuration"); DispStr(1, 3, "Dependant on jumper settings (see Instructions)"); DispStr(1, 4, "--------------------------------"); DispStr(1, 5, "0 = Unipolar 0 to +10v"); DispStr(1, 6, "1 = Bipolar -10 to +10v"); DispStr(1, 8, "Please enter the DAC configuration 0 - 1 = "); do { key = getchar() - '0'; } while (key < 0 || key > 1); printf("%d", key); // Configure the DAC for given configuration dac_mode = (key == 0 ? DAC_UNIPOLAR : DAC_BIPOLAR); anaOutConfig(dac_mode, DAC_SYNC); // set the min and max voltage based on DAC mode. max_volts = 10.0; min_volts = (dac_mode == DAC_BIPOLAR ? -10.0 : 0.0); // Initialize the DAC to output zero volts at the start anaOutVolts(CH0, 0); anaOutVolts(CH1, 0); anaOutStrobe(CH0_AND_CH1); channel_waveform[0] = SQUARE_WAVE; channel_waveform[1] = SINE_WAVE; // initialize waveform variables dac1_index = dac0_index = 0; phase_shift = 0; for (wave = 0; wave < NUM_WAVES; ++wave) { calc_waveform(waveform_signals[wave], ARRAY_SIZE, calc[waveform[wave]], min_volts, max_volts); } // print the menu once here, but it is located below "values table". DispStr(2, 16, "User Options:"); DispStr(2, 17, "-------------"); DispStr(2, 18, "1. Set waveform for DAC0."); DispStr(2, 19, "2. Set waveform for DAC1."); DispStr(2, 20, "3. Set phase shift."); while(1) { costate { // clear lines clearLines(12, 14); // print the current waveforms sprintf(display, "Current Waveforms: at %dHz", (int) WAVE_FREQUENCY); DispStr(2, 10, display); DispStr(2, 11, "----------------------------"); sprintf(display, "DAC0 = %s", waveform_names[channel_waveform[0]]); DispStr(2, 12, display); sprintf(display, "DAC1 = %s", waveform_names[channel_waveform[1]]); DispStr(2, 13, display); sprintf(display, "phase shift = %.2f%%", phase_shift); DispStr(2, 14, display); // NOTE: menu goes here sequentually, it is printed once above. // get response for menu choice do { waitfor(kbhit()); key = getchar() - '0'; } while (key < 0 || key > 3); switch (key) { case 1: // DAC 0: re-assign waveform case 2: // DAC 1: re-assign waveform channel = key - 1; // calculate channel from menu option. do { // display waveform options for (i = 0; i < NUM_WAVES; ++i) { sprintf(display, "%d: %s: ", i+1, waveform_names[i]); DispStr(3, 23+i, display); } sprintf(display, "Enter waveform for channel %d: ", channel); DispStr(3, 27, display); waitfor(kbhit()); wave = getchar() - '1'; } while (wave < 0 || wave >= NUM_WAVES); channel_waveform[channel] = wave; clearLines(23, 27); // clear the optional input line after the menu break; case 3: // re-assign phase shift do { sprintf(display, "Enter phase shift percentage (0 to 100): "); DispStr(3, 23, display); // Note: gets is a blocking function and will stop waveform. phase_shift = atof(gets(tmpbuf)); } while (phase_shift < 0 || phase_shift > 100); index_shift = (int) ((phase_shift * ARRAY_SIZE) / 100.0); dac1_index = (dac0_index + index_shift) % ARRAY_SIZE; clearLines(23, 23); // clear the optional input line after the menu break; } } costate { waitfor(DelayTicks(1)); anaOutStrobe(CH0_AND_CH1); anaOutVolts(CH0, waveform_signals[channel_waveform[CH0]][dac0_index]); anaOutVolts(CH1, waveform_signals[channel_waveform[CH1]][dac1_index]); dac0_index = (dac0_index + 1) % ARRAY_SIZE; dac1_index = (dac1_index + 1) % ARRAY_SIZE; } } // while (1) }
void TextMgr::clearLine(int16 row, byte color) { clearLines(row, row, color); }
/// // Perform a single game tick. // // This is just a state machine which is repeatedly called from the main // game loop. We do not want a 1 frame delay for some actions so we allow // some to run 'instantly'. /// void fsGameTick(FSEngine *f, const FSInput *i) { i8 distance; bool moved = false, rotated = false; f->se = 0; f->totalTicksRaw++; // TODO: Remove lastInput since unused f->lastInput = *i; // Always handle restart/quit events at any time. if (i->extra & FST_INPUT_RESTART) { f->state = FSS_RESTART; } if (i->extra & FST_INPUT_QUIT) { f->state = FSS_QUIT; } // Always update the current piece finesse counters if (i->extra & FST_INPUT_FINESSE_ROTATE) { f->pieceRotateCount += 1; } if (i->extra & FST_INPUT_FINESSE_MOVE) { f->pieceMovePressCount += 1; } // Always count the number of new keys pressed f->totalKeysPressed += i->newKeysCount; beginTick: switch (f->state) { case FSS_READY: case FSS_GO: // Ready, Go has has slightly different hold mechanics. Since we do not // yet have a piece we need to copy directly from the next queue to the // hold piece. Further, we can optionally hold as many times as we want // so need to discard the hold piece if required. if ((i->extra & FST_INPUT_HOLD) && f->holdAvailable) { f->holdPiece = nextPreviewPiece(f); f->se |= FST_SE_FLAG_HOLD; if (!f->infiniteReadyGoHold) { f->holdAvailable = false; } } if (f->genericCounter == 0) { f->se |= FST_SE_FLAG_READY; } if (f->genericCounter == TICKS(f->readyPhaseLength)) { f->se |= FST_SE_FLAG_GO; f->state = FSS_GO; } // This cannot be an `else if` since goPhaseLength could be 0. if (f->genericCounter == TICKS(f->readyPhaseLength) + TICKS(f->goPhaseLength)) { f->state = FSS_NEW_PIECE; } f->genericCounter++; // We need an explicit return here to avoid incrementing `totalTicks return; case FSS_ARE: // Even if ARE is instant, we still want to check for IHS and IRS state. // This allows the following behaviour: // // Currently we should be able to have three different actions for an initial // action: // // NONE - IRS/IHS disabled and not checked // HELD - Allows input action to remain set from last piece // HIT - Requires a new input action to trigger (not implemented) // // If ARE can be cancelled then the action will occur on the next // frame with the piece already playable. // This may need some more tweaking since during fast play initial stack // far too easily. if (f->initialActionStyle == FST_IA_PERSISTENT) { // Only check the current key state. // This is only dependent on the value on the final frame before the // piece spawns. Could adjust to allow any mid-ARE initial action to // stick till spawn. // We need an implicit ordering here so are slightly biased. May want to // give an option to adjust this ordering or have a stricter // order. if (i->currentKeys & FST_VK_FLAG_ROTR) { f->irsAmount = FST_ROT_CLOCKWISE; } else if (i->currentKeys & FST_VK_FLAG_ROTL) { f->irsAmount = FST_ROT_ANTICLOCKWISE; } else if (i->currentKeys & FST_VK_FLAG_ROTH) { f->irsAmount = FST_ROT_HALFTURN; } else { f->irsAmount = FST_ROT_NONE; } if (i->currentKeys & FST_VK_FLAG_HOLD) { f->ihsFlag = true; } else { f->ihsFlag = false; } } if (f->areCancellable && ( i->rotation != 0 || i->movement != 0 || i->gravity != 0 || i->extra != 0 || // We need to check ihs/irs since this is solely based on new // key state and otherwise may not be picked up. f->ihsFlag || f->irsAmount ) ) { f->areTimer = 0; f->state = FSS_NEW_PIECE; goto beginTick; } if (f->areTimer++ > TICKS(f->areDelay)) { f->areTimer = 0; f->state = FSS_NEW_PIECE; goto beginTick; } break; case FSS_NEW_PIECE: newPiece(f); // Apply ihs/irs before checking lockout. if (f->irsAmount != FST_ROT_NONE) { doRotate(f, f->irsAmount); } if (f->ihsFlag) { tryHold(f); } f->irsAmount = FST_ROT_NONE; f->ihsFlag = false; // Check lockout (irs/ihs has been applied already) if (isCollision(f, f->x, f->y, f->theta)) { f->state = FSS_GAMEOVER; goto beginTick; } updateHardDropY(f); f->state = FSS_FALLING; break; case FSS_FALLING: case FSS_LANDED: // If a hard drop occurs we want to immediately drop the piece and not // apply any other movement. This is far more natural and results in // less misdrops than if movement is processed prior. // // See issue #49 for details. if ((i->extra & FST_INPUT_HARD_DROP) || // We must recheck the lock timer state here since we may have // moved back to FALLING from LANDED on the last frame and do // **not** want to lock in mid-air! (f->lockTimer >= TICKS(f->lockDelay) && f->state == FSS_LANDED)) { f->state = FSS_LINES; // Still need to apply piece gravity before entering FSS_LINES. doPieceGravity(f, i->gravity); break; } if (i->extra & FST_INPUT_HOLD) { tryHold(f); } if (i->rotation) { if (doRotate(f, i->rotation)) { rotated = true; } } // Left movement distance = i->movement; for (; distance < 0; ++distance) { if (!isCollision(f, f->x - 1, f->y, f->theta)) { f->x -= 1; moved = true; } } // Right movement for (; distance > 0; --distance) { if (!isCollision(f, f->x + 1, f->y, f->theta)) { f->x += 1; moved = true; } } if (moved || rotated) { if (moved) { f->se |= FST_SE_FLAG_MOVE; } if (rotated) { f->se |= FST_SE_FLAG_ROTATE; } updateHardDropY(f); } doPieceGravity(f, i->gravity); // This must occur after we process the lockTimer to allow floorkick // limits to be processed correctly. If we encounter a floorkick limit // we set the lockTimer to max to allow a lock next frame, while still // giving the user an option to perform a move/rotate input. if ((moved || rotated) && f->lockStyle == FST_LOCK_MOVE) { f->lockTimer = 0; } if (f->state == FSS_LANDED) { f->lockTimer++; } break; case FSS_LINES: lockPiece(f); // NOTE: Make this conversion less *magic* f->se |= (1 << (FST_SE_IPIECE + f->piece)); f->piece = FS_NONE; const int lines = clearLines(f); if (0 < lines && lines <= 4) { // NOTE: Make this conversion less *magic* f->se |= (FST_SE_FLAG_ERASE1 << (lines - 1)); } f->linesCleared += lines; f->state = f->linesCleared < f->goal ? FSS_ARE : FSS_GAMEOVER; goto beginTick; case FSS_GAMEOVER: f->se |= FST_SE_FLAG_GAMEOVER; /* FALLTHROUGH */ case FSS_QUIT: case FSS_RESTART: break; default: fsLogError("Unknown state entered!"); break; } f->totalTicks += 1; }
void RS_ActionDrawEllipseInscribe::finish(bool updateTB){ clearLines(false); RS_PreviewActionInterface::finish(updateTB); }