void TabReplays::openRemoteReplayFinished(const Response &r) { if (r.response_code() != Response::RespOk) return; const Response_ReplayDownload &resp = r.GetExtension(Response_ReplayDownload::ext); GameReplay *replay = new GameReplay; replay->ParseFromString(resp.replay_data()); emit openReplay(replay); }
void TabReplays::actOpenLocalReplay() { QModelIndex curLeft = localDirView->selectionModel()->currentIndex(); if (localDirModel->isDir(curLeft)) return; QString filePath = localDirModel->filePath(curLeft); QFile f(filePath); if (!f.open(QIODevice::ReadOnly)) return; QByteArray data = f.readAll(); f.close(); GameReplay *replay = new GameReplay; replay->ParseFromArray(data.data(), data.size()); emit openReplay(replay); }
void MainWindow::actWatchReplay() { QFileDialog dlg(this, tr("Load replay")); dlg.setDirectory(settingsCache->getReplaysPath()); dlg.setNameFilters(QStringList() << QObject::tr("Cockatrice replays (*.cor)")); if (!dlg.exec()) return; QString fileName = dlg.selectedFiles().at(0); QFile file(fileName); if (!file.open(QIODevice::ReadOnly)) return; QByteArray buf = file.readAll(); file.close(); GameReplay *replay = new GameReplay; replay->ParseFromArray(buf.data(), buf.size()); tabSupervisor->openReplay(replay); }