|
| 1 | +/***************************************************************************** |
| 2 | + * |
| 3 | + * PROJECT: Multi Theft Auto |
| 4 | + * LICENSE: See LICENSE in the top level directory |
| 5 | + * FILE: mods/shared_logic/luadefs/CLuaPostfxDefs.cpp |
| 6 | + * PURPOSE: Lua definitions class |
| 7 | + * |
| 8 | + * Multi Theft Auto is available from https://www.multitheftauto.com/ |
| 9 | + * |
| 10 | + *****************************************************************************/ |
| 11 | + |
| 12 | +#include "StdInc.h" |
| 13 | +#include "CLuaPostfxDefs.h" |
| 14 | +#include <lua/CLuaFunctionParser.h> |
| 15 | + |
| 16 | +void CLuaPostfxDefs::LoadFunctions() |
| 17 | +{ |
| 18 | + constexpr static const std::pair<const char*, lua_CFunction> functions[]{ |
| 19 | + {"getPostFXValue", ArgumentParser<GetPostFXValue>}, |
| 20 | + {"getPostFXMode", ArgumentParser<GetPostFXMode>}, |
| 21 | + {"isPostFXEnabled", ArgumentParser<IsPostFXEnabled>}, |
| 22 | + }; |
| 23 | + |
| 24 | + // Add functions |
| 25 | + for (const auto& [name, func] : functions) |
| 26 | + CLuaCFunctions::AddFunction(name, func); |
| 27 | +} |
| 28 | + |
| 29 | +std::variant<float, bool> CLuaPostfxDefs::GetPostFXValue(int type) |
| 30 | +{ |
| 31 | + switch (static_cast<int>(type)) |
| 32 | + { |
| 33 | + case 0: // Gamma |
| 34 | + return g_pCore->GetCVars()->GetValue<float>("borderless_gamma_power", 0.0f); |
| 35 | + case 1: // Brightness |
| 36 | + return g_pCore->GetCVars()->GetValue<float>("borderless_brightness_scale", 0.0f); |
| 37 | + case 2: // Contrast |
| 38 | + return g_pCore->GetCVars()->GetValue<float>("borderless_contrast_scale", 0.0f); |
| 39 | + case 3: // Saturation |
| 40 | + return g_pCore->GetCVars()->GetValue<float>("borderless_saturation_scale", 0.0f); |
| 41 | + default: |
| 42 | + return false; |
| 43 | + } |
| 44 | +} |
| 45 | + |
| 46 | +int CLuaPostfxDefs::GetPostFXMode() |
| 47 | +{ |
| 48 | + return g_pCore->GetCVars()->GetValue<bool>("borderless_apply_fullscreen", false) ? 1 |
| 49 | + : g_pCore->GetCVars()->GetValue<bool>("borderless_apply_windowed", false) ? 2 |
| 50 | + : 0; |
| 51 | +} |
| 52 | + |
| 53 | +bool CLuaPostfxDefs::IsPostFXEnabled(int type) |
| 54 | +{ |
| 55 | + switch (static_cast<int>(type)) |
| 56 | + { |
| 57 | + case 0: // Gamma |
| 58 | + return g_pCore->GetCVars()->GetValue<bool>("borderless_gamma_enabled", false); |
| 59 | + case 1: // Brightness |
| 60 | + return g_pCore->GetCVars()->GetValue<bool>("borderless_brightness_enabled", false); |
| 61 | + case 2: // Contrast |
| 62 | + return g_pCore->GetCVars()->GetValue<bool>("borderless_contrast_enabled", false); |
| 63 | + case 3: // Saturation |
| 64 | + return g_pCore->GetCVars()->GetValue<bool>("borderless_saturation_enabled", false); |
| 65 | + default: |
| 66 | + return false; |
| 67 | + } |
| 68 | +} |
0 commit comments