2019-08-17 13:40:58 -06:00
|
|
|
// Copyright 2019 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#include "InputCommon/DynamicInputTextureManager.h"
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
#include "Common/CommonPaths.h"
|
|
|
|
#include "Common/FileSearch.h"
|
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Core/ConfigManager.h"
|
2021-02-02 22:04:33 -07:00
|
|
|
#include "Core/Core.h"
|
2019-08-17 13:40:58 -06:00
|
|
|
|
2021-02-14 19:47:00 -07:00
|
|
|
#include "InputCommon/DynamicInputTextures/DITConfiguration.h"
|
2019-08-17 13:40:58 -06:00
|
|
|
#include "VideoCommon/HiresTextures.h"
|
2021-02-02 22:04:33 -07:00
|
|
|
#include "VideoCommon/RenderBase.h"
|
2019-08-17 13:40:58 -06:00
|
|
|
|
|
|
|
namespace InputCommon
|
|
|
|
{
|
|
|
|
DynamicInputTextureManager::DynamicInputTextureManager() = default;
|
|
|
|
|
|
|
|
DynamicInputTextureManager::~DynamicInputTextureManager() = default;
|
|
|
|
|
|
|
|
void DynamicInputTextureManager::Load()
|
|
|
|
{
|
|
|
|
m_configuration.clear();
|
|
|
|
|
|
|
|
const std::string& game_id = SConfig::GetInstance().GetGameID();
|
|
|
|
const std::set<std::string> dynamic_input_directories =
|
|
|
|
GetTextureDirectoriesWithGameId(File::GetUserPath(D_DYNAMICINPUT_IDX), game_id);
|
|
|
|
|
|
|
|
for (const auto& dynamic_input_directory : dynamic_input_directories)
|
|
|
|
{
|
|
|
|
const auto json_files = Common::DoFileSearch({dynamic_input_directory}, {".json"});
|
|
|
|
for (auto& file : json_files)
|
|
|
|
{
|
|
|
|
m_configuration.emplace_back(file);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-27 15:41:50 -07:00
|
|
|
void DynamicInputTextureManager::GenerateTextures(const IniFile& file,
|
|
|
|
const std::vector<std::string>& controller_names)
|
2019-08-17 13:40:58 -06:00
|
|
|
{
|
2021-02-02 22:04:33 -07:00
|
|
|
bool any_dirty = false;
|
2019-08-17 13:40:58 -06:00
|
|
|
for (const auto& configuration : m_configuration)
|
|
|
|
{
|
2021-02-27 15:41:50 -07:00
|
|
|
any_dirty |= configuration.GenerateTextures(file, controller_names);
|
2019-08-17 13:40:58 -06:00
|
|
|
}
|
2021-02-02 22:04:33 -07:00
|
|
|
|
|
|
|
if (any_dirty && g_renderer && Core::GetState() != Core::State::Starting)
|
|
|
|
g_renderer->ForceReloadTextures();
|
2019-08-17 13:40:58 -06:00
|
|
|
}
|
|
|
|
} // namespace InputCommon
|