|
35 | 35 | #include "imgui.h"
|
36 | 36 | #include "imgui_impl_glfw.h"
|
37 | 37 | #include "imgui_impl_opengl3.h"
|
| 38 | +#include "imgui_stdlib.h" |
38 | 39 |
|
39 | 40 | #include "core/cdrom.h"
|
40 | 41 | #include "core/gpu.h"
|
@@ -403,7 +404,23 @@ void PCSX::GUI::endFrame() {
|
403 | 404 | }
|
404 | 405 | ImGui::Separator();
|
405 | 406 | if (ImGui::BeginMenu(_("Configuration"))) {
|
406 |
| - ImGui::MenuItem(_("Emulation"), nullptr, &m_showCfg); |
| 407 | + if (ImGui::MenuItem(_("Emulation"), nullptr, &m_showCfg)) { |
| 408 | + auto& overlays = g_emulator.settings.get<Emulator::SettingBiosOverlay>(); |
| 409 | + m_overlayFileOffsets.resize(overlays.size()); |
| 410 | + m_overlayLoadOffsets.resize(overlays.size()); |
| 411 | + m_overlayLoadSizes.resize(overlays.size()); |
| 412 | + unsigned counter = 0; |
| 413 | + for (auto& overlay : overlays) { |
| 414 | + char str[32]; |
| 415 | + std::snprintf(str, 32, "0x%08x", overlay.get<Emulator::OverlaySetting::FileOffset>().value); |
| 416 | + m_overlayFileOffsets[counter] = str; |
| 417 | + std::snprintf(str, 32, "0x%08x", overlay.get<Emulator::OverlaySetting::LoadOffset>().value); |
| 418 | + m_overlayLoadOffsets[counter] = str; |
| 419 | + std::snprintf(str, 32, "0x%08x", overlay.get<Emulator::OverlaySetting::LoadSize>().value); |
| 420 | + m_overlayLoadSizes[counter] = str; |
| 421 | + counter++; |
| 422 | + } |
| 423 | + } |
407 | 424 | ImGui::MenuItem(_("GPU"), nullptr, &PCSX::g_emulator.m_gpu->m_showCfg);
|
408 | 425 | ImGui::MenuItem(_("SPU"), nullptr, &PCSX::g_emulator.m_spu->m_showCfg);
|
409 | 426 | ImGui::EndMenu();
|
@@ -612,6 +629,7 @@ static void ShowHelpMarker(const char* desc) {
|
612 | 629 | bool PCSX::GUI::configure() {
|
613 | 630 | bool changed = false;
|
614 | 631 | bool selectBiosDialog = false;
|
| 632 | + bool selectBiosOverlayDialog = false; |
615 | 633 | auto& settings = PCSX::g_emulator.settings;
|
616 | 634 | if (!m_showCfg) return false;
|
617 | 635 |
|
@@ -689,16 +707,105 @@ bool PCSX::GUI::configure() {
|
689 | 707 | changed |= ImGui::Checkbox(_("BIOS HLE"), &settings.get<Emulator::SettingHLE>().value);
|
690 | 708 | changed |= ImGui::Checkbox(_("Fast boot"), &settings.get<Emulator::SettingFastBoot>().value);
|
691 | 709 | auto bios = settings.get<Emulator::SettingBios>().string();
|
692 |
| - ImGui::InputText(_("BIOS file"), const_cast<char*>(reinterpret_cast<const char*>(bios.c_str())), bios.length(), ImGuiInputTextFlags_ReadOnly); |
| 710 | + ImGui::InputText(_("BIOS file"), const_cast<char*>(reinterpret_cast<const char*>(bios.c_str())), bios.length(), |
| 711 | + ImGuiInputTextFlags_ReadOnly); |
693 | 712 | ImGui::SameLine();
|
694 | 713 | selectBiosDialog = ImGui::Button("...");
|
| 714 | + if (ImGui::CollapsingHeader(_("Advanced BIOS patching"))) { |
| 715 | + auto& overlays = settings.get<Emulator::SettingBiosOverlay>(); |
| 716 | + if (ImGui::Button(_("Add one entry"))) overlays.push_back({}); |
| 717 | + m_overlayFileOffsets.resize(overlays.size()); |
| 718 | + m_overlayLoadOffsets.resize(overlays.size()); |
| 719 | + m_overlayLoadSizes.resize(overlays.size()); |
| 720 | + int counter = 0; |
| 721 | + int overlayToRemove = -1; |
| 722 | + int swapMe = -1; |
| 723 | + for (auto& overlay : overlays) { |
| 724 | + std::string id = "overlay" + std::to_string(counter); |
| 725 | + ImGui::BeginChild(id.c_str(), ImVec2(0, ImGui::GetTextLineHeightWithSpacing() * 7.0f), true); |
| 726 | + auto overlayFilename = overlay.get<Emulator::OverlaySetting::Filename>().string(); |
| 727 | + ImGui::InputText(_("Filename"), |
| 728 | + const_cast<char*>(reinterpret_cast<const char*>(overlayFilename.c_str())), |
| 729 | + overlayFilename.length(), ImGuiInputTextFlags_ReadOnly); |
| 730 | + ImGui::SameLine(); |
| 731 | + if (ImGui::Button("...")) { |
| 732 | + selectBiosOverlayDialog = true; |
| 733 | + m_selectedBiosOverlayId = counter; |
| 734 | + } |
| 735 | + if (ImGui::InputText(_("File Offset"), &m_overlayFileOffsets[counter])) { |
| 736 | + char* endPtr; |
| 737 | + uint32_t offset = strtoul(m_overlayFileOffsets[counter].c_str(), &endPtr, 0); |
| 738 | + if (!m_overlayFileOffsets[counter].empty() && !*endPtr) { |
| 739 | + overlay.get<Emulator::OverlaySetting::FileOffset>().value = offset; |
| 740 | + changed = true; |
| 741 | + } |
| 742 | + } |
| 743 | + if (ImGui::InputText(_("Load Offset"), &m_overlayLoadOffsets[counter])) { |
| 744 | + char* endPtr; |
| 745 | + uint32_t offset = strtoul(m_overlayLoadOffsets[counter].c_str(), &endPtr, 0); |
| 746 | + if (!m_overlayLoadOffsets[counter].empty() && !*endPtr) { |
| 747 | + overlay.get<Emulator::OverlaySetting::LoadOffset>().value = offset; |
| 748 | + changed = true; |
| 749 | + } |
| 750 | + } |
| 751 | + if (ImGui::InputText(_("Load Size"), &m_overlayLoadSizes[counter])) { |
| 752 | + char* endPtr; |
| 753 | + uint32_t size = strtoul(m_overlayLoadSizes[counter].c_str(), &endPtr, 0); |
| 754 | + if (!m_overlayLoadSizes[counter].empty() && !*endPtr) { |
| 755 | + overlay.get<Emulator::OverlaySetting::LoadSize>().value = size; |
| 756 | + changed = true; |
| 757 | + } |
| 758 | + } |
| 759 | + if (ImGui::Checkbox(_("Enabled"), &overlay.get<Emulator::OverlaySetting::Enabled>().value)) |
| 760 | + changed = true; |
| 761 | + ImGui::SameLine(); |
| 762 | + if (ImGui::Button(_("Remove"))) { |
| 763 | + overlayToRemove = counter; |
| 764 | + } |
| 765 | + ImGui::SameLine(); |
| 766 | + if (ImGui::Button(_("Move up"))) { |
| 767 | + swapMe = counter - 1; |
| 768 | + } |
| 769 | + ImGui::SameLine(); |
| 770 | + if (ImGui::Button(_("Move down"))) { |
| 771 | + swapMe = counter; |
| 772 | + } |
| 773 | + ImGui::EndChild(); |
| 774 | + counter++; |
| 775 | + } |
| 776 | + if (overlayToRemove >= 0) { |
| 777 | + overlays.erase(overlays.begin() + overlayToRemove); |
| 778 | + changed = true; |
| 779 | + } |
| 780 | + if ((swapMe >= 0) && (swapMe != (overlays.size() - 1))) { |
| 781 | + std::iter_swap(overlays.begin() + swapMe, overlays.begin() + swapMe + 1); |
| 782 | + std::iter_swap(m_overlayFileOffsets.begin() + swapMe, m_overlayFileOffsets.begin() + swapMe + 1); |
| 783 | + std::iter_swap(m_overlayLoadOffsets.begin() + swapMe, m_overlayLoadOffsets.begin() + swapMe + 1); |
| 784 | + std::iter_swap(m_overlayLoadSizes.begin() + swapMe, m_overlayLoadSizes.begin() + swapMe + 1); |
| 785 | + changed = true; |
| 786 | + } |
| 787 | + } |
695 | 788 | }
|
696 | 789 | ImGui::End();
|
697 | 790 |
|
698 | 791 | if (selectBiosDialog) m_selectBiosDialog.openDialog();
|
699 | 792 | if (m_selectBiosDialog.draw()) {
|
700 | 793 | std::vector<PCSX::u8string> fileToOpen = m_selectBiosDialog.selected();
|
701 |
| - if (!fileToOpen.empty()) settings.get<Emulator::SettingBios>().value = fileToOpen[0]; |
| 794 | + if (!fileToOpen.empty()) { |
| 795 | + settings.get<Emulator::SettingBios>().value = fileToOpen[0]; |
| 796 | + changed = true; |
| 797 | + } |
| 798 | + } |
| 799 | + |
| 800 | + if (selectBiosOverlayDialog) m_selectBiosOverlayDialog.openDialog(); |
| 801 | + if (m_selectBiosOverlayDialog.draw()) { |
| 802 | + std::vector<PCSX::u8string> fileToOpen = m_selectBiosOverlayDialog.selected(); |
| 803 | + if (!fileToOpen.empty()) { |
| 804 | + settings.get<Emulator::SettingBiosOverlay>()[m_selectedBiosOverlayId] |
| 805 | + .get<Emulator::OverlaySetting::Filename>() |
| 806 | + .value = fileToOpen[0]; |
| 807 | + changed = true; |
| 808 | + } |
702 | 809 | }
|
703 | 810 | return changed;
|
704 | 811 | }
|
|
0 commit comments