| 352 | } |
| 353 | |
| 354 | void RegisterView::fetchNewValue(u64 currentValue, bool segment, std::function<void(u64)> callback) |
| 355 | { |
| 356 | const int categoryIndex = ui.registerTabs->currentIndex(); |
| 357 | const bool floatingPoint = CAT_SHOW_FLOAT && segment; |
| 358 | const int regSize = cpu().getRegisterSize(categoryIndex); |
| 359 | |
| 360 | QString existingValue("%1"); |
| 361 | |
| 362 | if (!floatingPoint) |
| 363 | existingValue = existingValue.arg(currentValue, regSize == 64 ? 16 : 8, 16, QChar('0')); |
| 364 | else |
| 365 | existingValue = existingValue.arg(std::bit_cast<float>((u32)currentValue)); |
| 366 | |
| 367 | //: Changing the value in a CPU register (e.g. "Change t0") |
| 368 | const QString title = tr("Change %1").arg(cpu().getRegisterName(categoryIndex, m_selectedRow)); |
| 369 | |
| 370 | AsyncDialogs::getText(this, title, "", existingValue, [this, callback, floatingPoint](QString input) { |
| 371 | u64 value; |
| 372 | if (!floatingPoint) // Get input as hexadecimal |
| 373 | { |
| 374 | bool ok; |
| 375 | value = input.toULongLong(&ok, 16); |
| 376 | if (!ok) |
| 377 | { |
| 378 | AsyncDialogs::warning(this, tr("Invalid register value"), tr("Invalid hexadecimal register value.")); |
| 379 | return; |
| 380 | } |
| 381 | } |
| 382 | else |
| 383 | { |
| 384 | bool ok; |
| 385 | value = std::bit_cast<u32>(input.toFloat(&ok)); |
| 386 | if (!ok) |
| 387 | { |
| 388 | AsyncDialogs::warning(this, tr("Invalid register value"), tr("Invalid floating-point register value.")); |
| 389 | return; |
| 390 | } |
| 391 | } |
| 392 | |
| 393 | callback(value); |
| 394 | }); |
| 395 | } |
| 396 | |
| 397 | void RegisterView::contextChangeValue() |
| 398 | { |
nothing calls this directly
no test coverage detected