void ScriptDebuggerPrivate::interactive() { setCurrentFrameIndex(0); QString qsdbgPrompt = QString::fromLatin1("(qsdbg) "); QString dotPrompt = QString::fromLatin1(".... "); QString prompt = qsdbgPrompt; QString code; forever { *m_outputStream << prompt; m_outputStream->flush(); QString line = readLine(); if (code.isEmpty() && (line.isEmpty() || line.startsWith(m_commandPrefix))) { if (line.isEmpty()) line = m_lastInteractiveCommand; else m_lastInteractiveCommand = line; QStringList parts = line.split(QLatin1Char(' '), QString::SkipEmptyParts); if (!parts.isEmpty()) { QString command = parts.takeFirst().mid(1); if (executeCommand(command, parts)) break; } } else { if (line.isEmpty()) continue; code += line; code += QLatin1Char('\n'); if (line.trimmed().isEmpty()) { continue; } else if (! engine()->canEvaluate(code)) { prompt = dotPrompt; } else { setMode(Run); QScriptValue result = engine()->evaluate(code, QLatin1String("typein")); code.clear(); prompt = qsdbgPrompt; if (! result.isUndefined()) { errorMessage(result.toString()); engine()->clearExceptions(); } } } } }
//============================================================== // Функция вызывается при перемещении мыши //============================================================== void FormAnimation::mouseMoveEvent(QMouseEvent *event) { if (frameCount_ == 0) return; const QPoint pos = event->pos(); int currentFrameIndex = pos.x() / FrameWidth; if (currentFrameIndex < 0) currentFrameIndex = 0; if (currentFrameIndex >= frameCount_) currentFrameIndex = frameCount_ - 1; setCurrentFrameIndex(currentFrameIndex); repaint(); }
void VMotiveFrame::init() { m_PlayBack = false; m_bDoneStop = true; m_PlayType = ptNone; m_bAutoHide = false; m_PlayCount = 0; m_PassCount = 0; m_CurrentFrameIdx = -1; m_pBmpFrame = 0; m_PlayTime_S = 0.0; m_PlayInterval_S = 0.7; m_PassTime = 0; m_TimeFlag = 0; m_StopIdx = 0; m_LastFrameIdx = -1; this->setWidth(m_ClipCanvas.getClipWidth()); this->setHeight(m_ClipCanvas.getClipHeight()); setCurrentFrameIndex(0); }
void Cursor::addCursorFrames(uint16 id) { PegasusEngine *vm = (PegasusEngine *)g_engine; Common::SeekableReadStream *cursStream = vm->_resFork->getResource(MKTAG('C', 'u', 'r', 's'), id); if (!cursStream) error("Could not load cursor frames set %d", id); uint16 frameCount = cursStream->readUint16BE(); for (uint16 i = 0; i < frameCount; i++) { CursorInfo info; info.tag = cursStream->readUint16BE(); info.hotspot.x = cursStream->readUint16BE(); info.hotspot.y = cursStream->readUint16BE(); info.surface = 0; info.palette = 0; info.colorCount = 0; _info.push_back(info); } delete cursStream; setCurrentFrameIndex(0); }
bool ScriptDebuggerPrivate::executeCommand(const QString &command, const QStringList &args) { if (command == QLatin1String("c") || command == QLatin1String("continue")) { setMode(Run); return true; } else if (command == QLatin1String("s") || command == QLatin1String("step")) { setMode(StepInto); return true; } else if (command == QLatin1String("n") || command == QLatin1String("next")) { setMode(StepOver); m_stepDepth = 0; return true; } else if (command == QLatin1String("f") || command == QLatin1String("frame")) { bool ok = false; int index = args.value(0).toInt(&ok); if (ok) { if (index < 0 || index >= frameCount()) { errorMessage("No such frame."); } else { setCurrentFrameIndex(index); QScriptContext *ctx = currentFrameContext(); message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString())); } } } else if (command == QLatin1String("bt") || command == QLatin1String("backtrace")) { QScriptContext *ctx = engine()->currentContext(); int index = -1; while (ctx) { ++index; QString line = ctx->toString(); message(QString::fromLatin1("#%0 %1").arg(index).arg(line)); ctx = ctx->parentContext(); } } else if (command == QLatin1String("up")) { int index = currentFrameIndex() + 1; if (index == frameCount()) { errorMessage(QString::fromLatin1("Initial frame selected; you cannot go up.")); } else { setCurrentFrameIndex(index); QScriptContext *ctx = currentFrameContext(); message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString())); } } else if (command == QLatin1String("down")) { int index = currentFrameIndex() - 1; if (index < 0) { errorMessage(QString::fromLatin1("Bottom (innermost) frame selected; you cannot go down.")); } else { setCurrentFrameIndex(index); QScriptContext *ctx = currentFrameContext(); message(QString::fromLatin1("#%0 %1").arg(index).arg(ctx->toString())); } } else if (command == QLatin1String("b") || command == QLatin1String("break")) { QString str = args.value(0); int colonIndex = str.indexOf(QLatin1Char(':')); if (colonIndex != -1) { // filename:line form QString fileName = str.left(colonIndex); int lineNumber = str.mid(colonIndex+1).toInt(); int id = m_bpManager->setBreakpoint(fileName, lineNumber); message(QString::fromLatin1("Breakpoint %0 at %1, line %2.").arg(id+1).arg(fileName).arg(lineNumber)); } else { // function QScriptValue fun = engine()->globalObject().property(str); if (fun.isFunction()) { int id = m_bpManager->setBreakpoint(fun); message(QString::fromLatin1("Breakpoint %0 at %1().").arg(id+1).arg(str)); } } } else if (command == QLatin1String("d") || command == QLatin1String("delete")) { int id = args.value(0).toInt() - 1; m_bpManager->removeBreakpoint(id); } else if (command == QLatin1String("disable")) { int id = args.value(0).toInt() - 1; m_bpManager->setBreakpointEnabled(id, false); } else if (command == QLatin1String("enable")) { int id = args.value(0).toInt() - 1; m_bpManager->setBreakpointEnabled(id, true); } else if (command == QLatin1String("list")) { QScriptContext *ctx = currentFrameContext(); ScriptInfo *progInfo = scriptInfo(ctx); if (!progInfo) { errorMessage("No source text available for this frame."); } else { QScriptContextInfo ctxInfo(ctx); bool ok; int line = args.value(0).toInt(&ok); if (ok) { line = qMax(1, line - 5); } else { line = listLineNumber(); if (line == -1) line = qMax(progInfo->lineNumber(), ctxInfo.lineNumber() - 5); } for (int i = line; i < line + 10; ++i) { message(QString::fromLatin1("%0\t%1").arg(i).arg(progInfo->lineText(i))); } setListLineNumber(line + 10); } } else if (command == QLatin1String("info")) { if (args.size() < 1) { } else { QString what = args.value(0); if (what == QLatin1String("locals")) { QScriptValueIterator it(currentFrameContext()->activationObject()); while (it.hasNext()) { it.next(); QString line; line.append(it.name()); line.append(QLatin1String(" = ")); line.append(safeValueToString(it.value())); message(line); } } } } else if (command == QLatin1String("help")) { message("continue - continue execution\n" "step - step into statement\n" "next - step over statement\n" "list - show where you are\n" "\n" "break - set breakpoint\n" "delete - remove breakpoint\n" "disable - disable breakpoint\n" "enable - enable breakpoint\n" "\n" "backtrace - show backtrace\n" "up - one frame up\n" "down - one frame down\n" "frame - set frame\n" "\n" "info locals - show local variables"); } else { errorMessage(QString::fromLatin1("Undefined command \"%0\". Try \"help\".") .arg(command)); } return false; }
void Cursor::hide() { CursorMan.showMouse(false); setCurrentFrameIndex(0); ((PegasusEngine *)g_engine)->_gfx->markCursorAsDirty(); }