mirror of
				https://github.com/PancakeTAS/lsfg-vk.git
				synced 2025-10-30 07:01:10 +00:00 
			
		
		
		
	remove global config
This commit is contained in:
		
							parent
							
								
									df37e9356a
								
							
						
					
					
						commit
						8140e1ca13
					
				
					 1 changed files with 8 additions and 30 deletions
				
			
		| 
						 | 
					@ -14,7 +14,6 @@
 | 
				
			||||||
#include <poll.h>
 | 
					#include <poll.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include <unordered_map>
 | 
					#include <unordered_map>
 | 
				
			||||||
#include <string_view>
 | 
					 | 
				
			||||||
#include <filesystem>
 | 
					#include <filesystem>
 | 
				
			||||||
#include <algorithm>
 | 
					#include <algorithm>
 | 
				
			||||||
#include <exception>
 | 
					#include <exception>
 | 
				
			||||||
| 
						 | 
					@ -214,29 +213,14 @@ void Config::updateConfig(const std::string& file) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // parse global configuration
 | 
					    // parse global configuration
 | 
				
			||||||
    const toml::value globalTable = toml::find_or_default<toml::table>(toml, "global");
 | 
					    const toml::value globalTable = toml::find_or_default<toml::table>(toml, "global");
 | 
				
			||||||
    Configuration global{
 | 
					    const Configuration global{
 | 
				
			||||||
        .enable = toml::find_or(globalTable, "enable", false),
 | 
					        .dll =   toml::find_or(globalTable, "dll", std::string()),
 | 
				
			||||||
        .dll =    toml::find_or(globalTable, "dll", std::string()),
 | 
					 | 
				
			||||||
        .env =    parse_env(toml::find_or(globalTable, "env", std::string())),
 | 
					 | 
				
			||||||
        .multiplier =  toml::find_or(globalTable, "multiplier", size_t(2)),
 | 
					 | 
				
			||||||
        .flowScale =   toml::find_or(globalTable, "flow_scale", 1.0F),
 | 
					 | 
				
			||||||
        .performance = toml::find_or(globalTable, "performance_mode", false),
 | 
					 | 
				
			||||||
        .hdr = toml::find_or(globalTable, "hdr_mode", false),
 | 
					 | 
				
			||||||
        .e_present =   into_present(
 | 
					 | 
				
			||||||
            toml::find_or(globalTable, "experimental_present_mode", ""),
 | 
					 | 
				
			||||||
            VkPresentModeKHR::VK_PRESENT_MODE_FIFO_KHR),
 | 
					 | 
				
			||||||
        .e_fps_limit = toml::find_or(globalTable, "experimental_fps_limit", 0U),
 | 
					 | 
				
			||||||
        .valid = globalConf.valid // use the same validity flag
 | 
					        .valid = globalConf.valid // use the same validity flag
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (global.multiplier == 1) { // jank alarm
 | 
					 | 
				
			||||||
        global.enable = false;
 | 
					 | 
				
			||||||
        global.multiplier = 2;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // validate global configuration
 | 
					    // validate global configuration
 | 
				
			||||||
    if (global.multiplier < 1)
 | 
					    if (global.multiplier < 2)
 | 
				
			||||||
        throw std::runtime_error("Multiplier cannot be less than 1");
 | 
					        throw std::runtime_error("Global Multiplier cannot be less than 2");
 | 
				
			||||||
    if (global.flowScale < 0.25F || global.flowScale > 1.0F)
 | 
					    if (global.flowScale < 0.25F || global.flowScale > 1.0F)
 | 
				
			||||||
        throw std::runtime_error("Flow scale must be between 0.25 and 1.0");
 | 
					        throw std::runtime_error("Flow scale must be between 0.25 and 1.0");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -251,8 +235,7 @@ void Config::updateConfig(const std::string& file) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const std::string exe = toml::find<std::string>(gameTable, "exe");
 | 
					        const std::string exe = toml::find<std::string>(gameTable, "exe");
 | 
				
			||||||
        Configuration game{
 | 
					        Configuration game{
 | 
				
			||||||
            .enable = toml::find_or(gameTable, "enable", global.enable),
 | 
					            .enable = true,
 | 
				
			||||||
            .dll = toml::find_or(gameTable, "dll", global.dll),
 | 
					 | 
				
			||||||
            .env = parse_env(toml::find_or(gameTable, "env", std::string())),
 | 
					            .env = parse_env(toml::find_or(gameTable, "env", std::string())),
 | 
				
			||||||
            .multiplier = toml::find_or(gameTable, "multiplier", global.multiplier),
 | 
					            .multiplier = toml::find_or(gameTable, "multiplier", global.multiplier),
 | 
				
			||||||
            .flowScale = toml::find_or(gameTable, "flow_scale", global.flowScale),
 | 
					            .flowScale = toml::find_or(gameTable, "flow_scale", global.flowScale),
 | 
				
			||||||
| 
						 | 
					@ -265,11 +248,6 @@ void Config::updateConfig(const std::string& file) {
 | 
				
			||||||
            .valid = global.valid // only need a single validity flag
 | 
					            .valid = global.valid // only need a single validity flag
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (game.multiplier == 1) {
 | 
					 | 
				
			||||||
            game.enable = false;
 | 
					 | 
				
			||||||
            game.multiplier = 2;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // validate the configuration
 | 
					        // validate the configuration
 | 
				
			||||||
        if (game.multiplier < 1)
 | 
					        if (game.multiplier < 1)
 | 
				
			||||||
            throw std::runtime_error("Multiplier cannot be less than 1");
 | 
					            throw std::runtime_error("Multiplier cannot be less than 1");
 | 
				
			||||||
| 
						 | 
					@ -283,13 +261,13 @@ void Config::updateConfig(const std::string& file) {
 | 
				
			||||||
    gameConfs = std::move(games);
 | 
					    gameConfs = std::move(games);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Configuration Config::getConfig(std::string_view name) {
 | 
					Configuration Config::getConfig(const std::pair<std::string, std::string>& name) {
 | 
				
			||||||
    if (name.empty() || !gameConfs.has_value())
 | 
					    if (!gameConfs.has_value())
 | 
				
			||||||
        return globalConf;
 | 
					        return globalConf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const auto& games = *gameConfs;
 | 
					    const auto& games = *gameConfs;
 | 
				
			||||||
    auto it = std::ranges::find_if(games, [&name](const auto& pair) {
 | 
					    auto it = std::ranges::find_if(games, [&name](const auto& pair) {
 | 
				
			||||||
        return name.ends_with(pair.first);
 | 
					        return name.first.ends_with(pair.first) || (name.second == pair.first);
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    if (it != games.end())
 | 
					    if (it != games.end())
 | 
				
			||||||
        return it->second;
 | 
					        return it->second;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue