void CheatDialog::OnDeleteCheat() { if (newly_created) { newly_created = false; } else { Core::System::GetInstance().CheatEngine().RemoveCheat(ui->tableCheats->currentRow()); Core::System::GetInstance().CheatEngine().SaveCheatFile(); } LoadCheats(); if (cheats.empty()) { ui->lineName->setText(""); ui->textCode->setPlainText(""); ui->textNotes->setPlainText(""); ui->lineName->setEnabled(false); ui->textCode->setEnabled(false); ui->textNotes->setEnabled(false); ui->buttonDelete->setEnabled(false); last_row = last_col = -1; } else { if (last_row >= ui->tableCheats->rowCount()) { last_row = ui->tableCheats->rowCount() - 1; } ui->tableCheats->setCurrentCell(last_row, last_col); const auto& current_cheat = cheats[last_row]; ui->lineName->setText(QString::fromStdString(current_cheat->GetName())); ui->textNotes->setPlainText(QString::fromStdString(current_cheat->GetComments())); ui->textCode->setPlainText(QString::fromStdString(current_cheat->GetCode())); } edited = false; ui->buttonSave->setEnabled(false); ui->buttonAddCheat->setEnabled(true); }
CheatDialog::CheatDialog(QWidget* parent) : QDialog(parent), ui(std::make_unique<Ui::CheatDialog>()) { // Setup gui control settings ui->setupUi(this); setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint); ui->tableCheats->setColumnWidth(0, 30); ui->tableCheats->setColumnWidth(2, 85); ui->tableCheats->horizontalHeader()->setSectionResizeMode(0, QHeaderView::Fixed); ui->tableCheats->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch); ui->tableCheats->horizontalHeader()->setSectionResizeMode(2, QHeaderView::Fixed); ui->lineName->setEnabled(false); ui->textCode->setEnabled(false); ui->textNotes->setEnabled(false); const auto game_id = fmt::format( "{:016X}", Core::System::GetInstance().Kernel().GetCurrentProcess()->codeset->program_id); ui->labelTitle->setText(tr("Title ID: %1").arg(QString::fromStdString(game_id))); connect(ui->buttonClose, &QPushButton::released, this, &CheatDialog::OnCancel); connect(ui->buttonAddCheat, &QPushButton::released, this, &CheatDialog::OnAddCheat); connect(ui->tableCheats, &QTableWidget::cellClicked, this, &CheatDialog::OnRowSelected); connect(ui->lineName, &QLineEdit::textEdited, this, &CheatDialog::OnTextEdited); connect(ui->textNotes, &QPlainTextEdit::textChanged, this, &CheatDialog::OnTextEdited); connect(ui->textCode, &QPlainTextEdit::textChanged, this, &CheatDialog::OnTextEdited); connect(ui->buttonSave, &QPushButton::released, [this] { SaveCheat(ui->tableCheats->currentRow()); }); connect(ui->buttonDelete, &QPushButton::released, this, &CheatDialog::OnDeleteCheat); LoadCheats(); }
void MesenMovie::ApplySettings() { NesModel region = FromString(LoadString(_settings, MovieKeys::Region), NesModelNames, NesModel::NTSC); ConsoleType consoleType = FromString(LoadString(_settings, MovieKeys::ConsoleType), ConsoleTypeNames, ConsoleType::Nes); ControllerType controller1 = FromString(LoadString(_settings, MovieKeys::Controller1), ControllerTypeNames, ControllerType::None); ControllerType controller2 = FromString(LoadString(_settings, MovieKeys::Controller2), ControllerTypeNames, ControllerType::None); ControllerType controller3 = FromString(LoadString(_settings, MovieKeys::Controller3), ControllerTypeNames, ControllerType::None); ControllerType controller4 = FromString(LoadString(_settings, MovieKeys::Controller4), ControllerTypeNames, ControllerType::None); ExpansionPortDevice expansionDevice = FromString<ExpansionPortDevice>(LoadString(_settings, MovieKeys::ExpansionDevice), ExpansionPortDeviceNames, ExpansionPortDevice::None); EmulationSettings::SetNesModel(region); EmulationSettings::SetConsoleType(consoleType); EmulationSettings::SetControllerType(0, controller1); EmulationSettings::SetControllerType(1, controller2); EmulationSettings::SetControllerType(2, controller3); EmulationSettings::SetControllerType(3, controller4); EmulationSettings::SetExpansionDevice(expansionDevice); uint32_t ramPowerOnState = LoadInt(_settings, MovieKeys::RamPowerOnState); if(ramPowerOnState == 0xFF) { EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllOnes); } else { EmulationSettings::SetRamPowerOnState(RamPowerOnState::AllZeros); } EmulationSettings::SetInputPollScanline(LoadInt(_settings, MovieKeys::InputPollScanline, 240)); EmulationSettings::SetZapperDetectionRadius(LoadInt(_settings, MovieKeys::ZapperDetectionRadius)); uint32_t cpuClockRate = LoadInt(_settings, MovieKeys::CpuClockRate); if(cpuClockRate != 100) { bool adjustApu = LoadBool(_settings, MovieKeys::OverclockAdjustApu); EmulationSettings::SetOverclockRate(cpuClockRate, adjustApu); } else { EmulationSettings::SetOverclockRate(100, true); } EmulationSettings::SetPpuNmiConfig( LoadInt(_settings, MovieKeys::ExtraScanlinesBeforeNmi), LoadInt(_settings, MovieKeys::ExtraScanlinesAfterNmi) ); EmulationSettings::SetFlagState(EmulationFlags::DisablePpu2004Reads, LoadBool(_settings, MovieKeys::DisablePpu2004Reads)); EmulationSettings::SetFlagState(EmulationFlags::DisablePaletteRead, LoadBool(_settings, MovieKeys::DisablePaletteRead)); EmulationSettings::SetFlagState(EmulationFlags::DisableOamAddrBug, LoadBool(_settings, MovieKeys::DisableOamAddrBug)); EmulationSettings::SetFlagState(EmulationFlags::UseNes101Hvc101Behavior, LoadBool(_settings, MovieKeys::UseNes101Hvc101Behavior)); EmulationSettings::SetFlagState(EmulationFlags::EnableOamDecay, LoadBool(_settings, MovieKeys::EnableOamDecay)); EmulationSettings::SetFlagState(EmulationFlags::DisablePpuReset, LoadBool(_settings, MovieKeys::DisablePpuReset)); //VS System flags EmulationSettings::SetPpuModel(FromString(LoadString(_settings, MovieKeys::PpuModel), PpuModelNames, PpuModel::Ppu2C02)); EmulationSettings::SetDipSwitches(HexUtilities::FromHex(LoadString(_settings, MovieKeys::DipSwitches))); LoadCheats(); }
bool CheatDialog::SaveCheat(int row) { if (ui->lineName->text().isEmpty()) { QMessageBox::critical(this, tr("Save Cheat"), tr("Please enter a cheat name.")); return false; } if (ui->textCode->toPlainText().isEmpty()) { QMessageBox::critical(this, tr("Save Cheat"), tr("Please enter the cheat code.")); return false; } // Check if the cheat lines are valid auto code_lines = ui->textCode->toPlainText().split("\n", QString::SkipEmptyParts); for (int i = 0; i < code_lines.size(); ++i) { Cheats::GatewayCheat::CheatLine cheat_line(code_lines[i].toStdString()); if (cheat_line.valid) continue; auto answer = QMessageBox::warning( this, tr("Save Cheat"), tr("Cheat code line %1 is not valid.\nWould you like to ignore the error and continue?") .arg(i + 1), QMessageBox::Yes | QMessageBox::No, QMessageBox::No); if (answer == QMessageBox::No) return false; } auto cheat = std::make_shared<Cheats::GatewayCheat>(ui->lineName->text().toStdString(), ui->textCode->toPlainText().toStdString(), ui->textNotes->toPlainText().toStdString()); if (newly_created) { Core::System::GetInstance().CheatEngine().AddCheat(cheat); newly_created = false; } else { Core::System::GetInstance().CheatEngine().UpdateCheat(row, cheat); } Core::System::GetInstance().CheatEngine().SaveCheatFile(); int previous_row = ui->tableCheats->currentRow(); int previous_col = ui->tableCheats->currentColumn(); LoadCheats(); ui->tableCheats->setCurrentCell(previous_row, previous_col); edited = false; ui->buttonSave->setEnabled(false); ui->buttonAddCheat->setEnabled(true); return true; }
static void OnCheatListDlg_OpenClicked(GtkWidget *widget, gpointer user_data) { GtkWidget *chooser; gchar *filename; GtkFileFilter *filter; chooser = gtk_file_chooser_dialog_new (_("Open Cheat File"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); filename = g_build_filename(getenv("HOME"), CHEATS_DIR, NULL); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (chooser), filename); g_free(filename); filter = gtk_file_filter_new (); gtk_file_filter_add_pattern (filter, "*.cht"); gtk_file_filter_set_name (filter, _("PCSXR Cheat Code Files (*.cht)")); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); filter = gtk_file_filter_new (); gtk_file_filter_add_pattern (filter, "*"); gtk_file_filter_set_name (filter, _("All Files")); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (chooser), filter); if (gtk_dialog_run (GTK_DIALOG (chooser)) == GTK_RESPONSE_OK) { filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); gtk_widget_destroy (GTK_WIDGET (chooser)); while (gtk_events_pending()) gtk_main_iteration(); } else { gtk_widget_destroy (GTK_WIDGET (chooser)); while (gtk_events_pending()) gtk_main_iteration(); return; } LoadCheats(filename); g_free(filename); LoadCheatListItems(-1); }
void AppCoreThread::ApplySettings( const Pcsx2Config& src ) { // Used to track the current game serial/id, and used to disable verbose logging of // applied patches if the game info hasn't changed. (avoids spam when suspending/resuming // or using TAB or other things). static wxString curGameKey; // 'fixup' is the EmuConfig we're going to upload to the emulator, which very well may // differ from the user-configured EmuConfig settings. So we make a copy here and then // we apply the commandline overrides and database gamefixes, and then upload 'fixup' // to the global EmuConfig. // // Note: It's important that we apply the commandline overrides *before* database fixes. // The database takes precedence (if enabled). Pcsx2Config fixup( src ); const CommandlineOverrides& overrides( wxGetApp().Overrides ); if( overrides.DisableSpeedhacks || !g_Conf->EnableSpeedHacks ) fixup.Speedhacks.DisableAll(); if( overrides.ApplyCustomGamefixes ) { for (GamefixId id=GamefixId_FIRST; id < pxEnumEnd; ++id) fixup.Gamefixes.Set( id, overrides.Gamefixes.Get(id) ); } else if( !g_Conf->EnableGameFixes ) fixup.Gamefixes.DisableAll(); wxString gameCRC; wxString gameSerial; wxString gamePatch; wxString gameFixes; wxString gameCheats; wxString gameWsHacks; wxString gameName; wxString gameCompat; int numberLoadedCheats; int numberLoadedWideScreenPatches; int numberDbfCheatsLoaded; if (ElfCRC) gameCRC.Printf( L"%8.8x", ElfCRC ); if (!DiscSerial.IsEmpty()) gameSerial = L" [" + DiscSerial + L"]"; const wxString newGameKey( SysGetDiscID() ); const bool verbose( newGameKey != curGameKey ); curGameKey = newGameKey; if (!curGameKey.IsEmpty()) { if (IGameDatabase* GameDB = AppHost_GetGameDatabase() ) { Game_Data game; if (GameDB->findGame(game, curGameKey)) { int compat = game.getInt("Compat"); gameName = game.getString("Name"); gameName += L" (" + game.getString("Region") + L")"; gameCompat = L" [Status = "+compatToStringWX(compat)+L"]"; } if (EmuConfig.EnablePatches) { if (int patches = InitPatches(gameCRC, game)) { gamePatch.Printf(L" [%d Patches]", patches); if (verbose) Console.WriteLn(Color_Green, "(GameDB) Patches Loaded: %d", patches); } if (int fixes = loadGameSettings(fixup, game, verbose)) { gameFixes.Printf(L" [%d Fixes]", fixes); } } } } if (gameName.IsEmpty() && gameSerial.IsEmpty() && gameCRC.IsEmpty()) { // if all these conditions are met, it should mean that we're currently running BIOS code. // Chances are the BiosChecksum value is still zero or out of date, however -- because // the BIos isn't loaded until after initial calls to ApplySettings. gameName = L"Booting PS2 BIOS... "; } ResetCheatsCount(); //Till the end of this function, entry CRC will be 00000000 if (!gameCRC.Length()) { if (EmuConfig.EnableWideScreenPatches || EmuConfig.EnableCheats) { Console.WriteLn(Color_Gray, "Patches: No CRC, using 00000000 instead."); } gameCRC = L"00000000"; } // regular cheat patches if (EmuConfig.EnableCheats) { if (numberLoadedCheats = LoadCheats(gameCRC, GetCheatsFolder(), L"Cheats")) { gameCheats.Printf(L" [%d Cheats]", numberLoadedCheats); } } // wide screen patches if (EmuConfig.EnableWideScreenPatches) { if (numberLoadedWideScreenPatches = LoadCheats(gameCRC, GetCheatsWsFolder(), L"Widescreen hacks")) { gameWsHacks.Printf(L" [%d widescreen hacks]", numberLoadedWideScreenPatches); } else { // No ws cheat files found at the cheats_ws folder, try the ws cheats zip file. wxString cheats_ws_archive = Path::Combine(PathDefs::GetProgramDataDir(), wxFileName(L"cheats_ws.zip")); if (numberDbfCheatsLoaded = LoadCheatsFromZip(gameCRC, cheats_ws_archive)) { Console.WriteLn(Color_Green, "(Wide Screen Cheats DB) Patches Loaded: %d", numberDbfCheatsLoaded); gameWsHacks.Printf(L" [%d widescreen hacks]", numberDbfCheatsLoaded); } } } wxString consoleTitle = gameName + gameSerial; if (!gameSerial.IsEmpty()) { consoleTitle += L" [" + gameCRC.MakeUpper() + L"]"; } consoleTitle += gameCompat + gameFixes + gamePatch + gameCheats + gameWsHacks; Console.SetTitle(consoleTitle); // Re-entry guard protects against cases where code wants to manually set core settings // which are not part of g_Conf. The subsequent call to apply g_Conf settings (which is // usually the desired behavior) will be ignored. static int localc = 0; RecursionGuard guard( localc ); if( guard.IsReentrant() ) return; if( fixup == EmuConfig ) return; if( m_ExecMode >= ExecMode_Opened ) { ScopedCoreThreadPause paused_core; _parent::ApplySettings( fixup ); paused_core.AllowResume(); } else { _parent::ApplySettings( fixup ); } }