Game info screen: Show list of any plugins that will be loaded on start of the game

This commit is contained in:
Henrik Rydgård 2024-04-09 11:58:35 +02:00
parent bab6c5997b
commit e903287f4c
5 changed files with 54 additions and 33 deletions

View File

@ -180,13 +180,12 @@ public:
std::vector<std::unique_ptr<Section>> &Sections() { return sections; }
bool HasSection(const char *section) { return GetSection(section) != 0; }
bool HasSection(const char *section) { return GetSection(section) != nullptr; }
const Section* GetSection(const char* section) const;
Section* GetSection(const char* section);
Section* GetOrCreateSection(const char* section);
private:
std::vector<std::unique_ptr<Section>> sections;
const Section* GetSection(const char* section) const;
Section* GetSection(const char* section);
};

View File

@ -41,18 +41,6 @@ std::map<int, uint8_t> PluginDataKeys;
static bool anyEnabled = false;
static std::vector<std::string> prxPlugins;
enum class PluginType {
INVALID = 0,
PRX,
};
struct PluginInfo {
PluginType type;
std::string filename;
int version;
uint32_t memory;
};
static PluginInfo ReadPluginIni(const std::string &subdir, IniFile &ini) {
PluginInfo info;
@ -66,11 +54,16 @@ static PluginInfo ReadPluginIni(const std::string &subdir, IniFile &ini) {
}
if (options->Get("filename", &value, "")) {
info.name = value;
info.filename = "ms0:/PSP/PLUGINS/" + subdir + "/" + value;
} else {
info.type = PluginType::INVALID;
}
if (options->Get("name", &value, "")) {
info.name = value;
}
options->Get("version", &info.version, 0);
options->Get("memory", &info.memory, 0);
if (info.memory > 93) {
@ -89,7 +82,7 @@ static PluginInfo ReadPluginIni(const std::string &subdir, IniFile &ini) {
return info;
}
static std::vector<PluginInfo> FindPlugins(const std::string &gameID, const std::string &lang) {
std::vector<PluginInfo> FindPlugins(const std::string &gameID, const std::string &lang) {
std::vector<File::FileInfo> pluginDirs;
GetFilesInDir(GetSysDirectory(DIRECTORY_PLUGINS), &pluginDirs);
@ -110,23 +103,24 @@ static std::vector<PluginInfo> FindPlugins(const std::string &gameID, const std:
std::string gameIni;
// TODO: Should just use getsection and fail the ini if not found, I guess.
Section *games = ini.GetOrCreateSection("games");
if (games->Get(gameID.c_str(), &gameIni, "")) {
if (!strcasecmp(gameIni.c_str(), "true")) {
matches.insert("plugin.ini");
} else if (!strcasecmp(gameIni.c_str(), "false")){
continue;
} else if (!gameIni.empty()) {
matches.insert(gameIni);
const Section *games = ini.GetSection("games");
if (games) {
if (games->Get(gameID.c_str(), &gameIni, "")) {
if (!strcasecmp(gameIni.c_str(), "true")) {
matches.insert("plugin.ini");
} else if (!strcasecmp(gameIni.c_str(), "false")) {
continue;
} else if (!gameIni.empty()) {
matches.insert(gameIni);
}
}
}
if (games->Get("ALL", &gameIni, "")) {
if (!strcasecmp(gameIni.c_str(), "true")) {
matches.insert("plugin.ini");
} else if (!gameIni.empty()) {
matches.insert(gameIni);
if (games->Get("ALL", &gameIni, "")) {
if (!strcasecmp(gameIni.c_str(), "true")) {
matches.insert("plugin.ini");
} else if (!gameIni.empty()) {
matches.insert(gameIni);
}
}
}
@ -196,7 +190,7 @@ bool Load() {
ERROR_LOG(SYSTEM, "Unable to start plugin %s: %08x", filename.c_str(), ret);
} else {
std::string shortName = Path(filename).GetFilename();
g_OSD.Show(OSDType::MESSAGE_SUCCESS, ApplySafeSubstitutions(sy->T("Loaded plugin: %1"), shortName));
g_OSD.Show(OSDType::MESSAGE_SUCCESS, ApplySafeSubstitutions(sy->T("Loaded plugin: %1"), shortName), 6.0f);
started = true;
}

View File

@ -18,6 +18,7 @@
#pragma once
#include <cstdint>
#include <string>
#include "Input/KeyCodes.h"
class PointerWrap;
@ -34,6 +35,21 @@ void DoState(PointerWrap &p);
bool HasEnabled();
enum class PluginType {
INVALID = 0,
PRX,
};
struct PluginInfo {
PluginType type;
std::string name;
std::string filename; // PSP-space path. So we can't use a Path object.
int version;
uint32_t memory;
};
std::vector<PluginInfo> FindPlugins(const std::string &gameID, const std::string &lang);
void SetKey(int key, uint8_t value);
uint8_t GetKey(int key);

View File

@ -37,6 +37,7 @@
#include "Core/System.h"
#include "Core/Loaders.h"
#include "Core/Util/GameDB.h"
#include "Core/HLE/Plugins.h"
#include "UI/OnScreenDisplay.h"
#include "UI/CwCheatScreen.h"
#include "UI/EmuScreen.h"
@ -150,6 +151,16 @@ void GameScreen::CreateViews() {
tvVerified_ = infoLayout->Add(new NoticeView(NoticeLevel::INFO, ga->T("Click \"Calculate CRC\" to verify ISO"), "", new LinearLayoutParams(FILL_PARENT, WRAP_CONTENT)));
tvVerified_->SetVisibility(UI::V_GONE);
tvVerified_->SetSquishy(true);
// Show plugin info, if any. Later might add checkboxes.
auto plugins = HLEPlugins::FindPlugins(info->id, g_Config.sLanguageIni);
if (!plugins.empty()) {
auto sy = GetI18NCategory(I18NCat::SYSTEM);
infoLayout->Add(new TextView(sy->T("Plugins"), ALIGN_LEFT, true));
for (const auto &plugin : plugins) {
infoLayout->Add(new TextView(ApplySafeSubstitutions("* %1", plugin.name), ALIGN_LEFT, true));
}
}
} else {
tvTitle_ = nullptr;
tvID_ = nullptr;

View File

@ -1274,6 +1274,7 @@ Change CPU Clock = Mudar o clock da CPU do PSP emulado (instável)
CPU Core = Núcleo da CPU
Dynarec/JIT (recommended) = Dynarec/JIT (recomendado)
JIT using IR = JIT using IR
Plugins = Plugins
Loaded plugin: %1 = Plugin carregado: %1
Memory Stick folder = Pasta do cartão de memória
Memory Stick size = Tamanho do cartão de memória