| 4313 | } |
| 4314 | |
| 4315 | void TextureViewer::reloadCustomShaders(const QString &filter) |
| 4316 | { |
| 4317 | if(!m_Ctx.IsCaptureLoaded()) |
| 4318 | return; |
| 4319 | |
| 4320 | if(filter.isEmpty()) |
| 4321 | { |
| 4322 | QString prevtext = ui->customShader->currentText(); |
| 4323 | |
| 4324 | QList<ResourceId> shaders = m_CustomShaders.values(); |
| 4325 | |
| 4326 | m_Ctx.Replay().AsyncInvoke([shaders](IReplayController *r) { |
| 4327 | for(ResourceId s : shaders) |
| 4328 | r->FreeCustomShader(s); |
| 4329 | }); |
| 4330 | |
| 4331 | ui->customShader->clear(); |
| 4332 | m_CustomShaders.clear(); |
| 4333 | |
| 4334 | ui->customShader->setCurrentText(prevtext); |
| 4335 | } |
| 4336 | else |
| 4337 | { |
| 4338 | QString fn = QFileInfo(filter).fileName(); |
| 4339 | QString key = fn.toUpper(); |
| 4340 | |
| 4341 | if(m_CustomShaders.contains(key)) |
| 4342 | { |
| 4343 | if(m_CustomShadersBusy.contains(key)) |
| 4344 | return; |
| 4345 | |
| 4346 | ResourceId freed = m_CustomShaders[key]; |
| 4347 | m_Ctx.Replay().AsyncInvoke([freed](IReplayController *r) { r->FreeCustomShader(freed); }); |
| 4348 | |
| 4349 | m_CustomShaders.remove(key); |
| 4350 | |
| 4351 | QString text = ui->customShader->currentText(); |
| 4352 | |
| 4353 | for(int i = 0; i < ui->customShader->count(); i++) |
| 4354 | { |
| 4355 | if(ui->customShader->itemText(i).compare(fn, Qt::CaseInsensitive) == 0) |
| 4356 | { |
| 4357 | ui->customShader->removeItem(i); |
| 4358 | break; |
| 4359 | } |
| 4360 | } |
| 4361 | |
| 4362 | ui->customShader->setCurrentText(text); |
| 4363 | } |
| 4364 | } |
| 4365 | |
| 4366 | QStringList filters; |
| 4367 | for(auto it = encodingExtensions.begin(); it != encodingExtensions.end(); ++it) |
| 4368 | { |
| 4369 | if(!canCompileCustomShader(it.value())) |
| 4370 | continue; |
| 4371 | |
| 4372 | filters.push_back(lit("*.") + it.key()); |
no test coverage detected