Skip to content

Commit 90d2d6d

Browse files
committed
Switch to string instead of integer
1 parent 02f3f8b commit 90d2d6d

File tree

5 files changed

+49
-20
lines changed

5 files changed

+49
-20
lines changed

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -988,6 +988,13 @@ ADD_ENUM(VehicleAudioSettingProperty::VEHICLE_TYPE_FOR_AUDIO, "vehicle-type-for-
988988
IMPLEMENT_ENUM_CLASS_END("vehicle-audio-setting")
989989

990990

991+
IMPLEMENT_ENUM_CLASS_BEGIN(PostFXType)
992+
ADD_ENUM(PostFXType::GAMMA, "gamma")
993+
ADD_ENUM(PostFXType::BRIGHTNESS, "brightness")
994+
ADD_ENUM(PostFXType::CONTRAST, "contrast")
995+
ADD_ENUM(PostFXType::SATURATION, "saturation")
996+
IMPLEMENT_ENUM_CLASS_END("postfx-type")
997+
991998
//
992999
// CResource from userdata
9931000
//

Client/mods/deathmatch/logic/lua/CLuaFunctionParseHelpers.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "enums/SoundEffectParams.h"
2626
#include "enums/SoundEffectType.h"
2727
#include "enums/ObjectGroupPhysicalProperties.h"
28+
#include "enums/PostFXType.h"
2829

2930
enum eLuaType
3031
{
@@ -102,6 +103,7 @@ DECLARE_ENUM_CLASS(RestreamOption);
102103
DECLARE_ENUM_CLASS(taskType);
103104
DECLARE_ENUM(eEntityType);
104105
DECLARE_ENUM_CLASS(VehicleAudioSettingProperty);
106+
DECLARE_ENUM_CLASS(PostFXType);
105107

106108
class CRemoteCall;
107109

Client/mods/deathmatch/logic/luadefs/CLuaPostfxDefs.cpp

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,21 @@ void CLuaPostfxDefs::LoadFunctions()
2626
CLuaCFunctions::AddFunction(name, func);
2727
}
2828

29-
std::variant<float, bool> CLuaPostfxDefs::GetPostFXValue(int type)
29+
float CLuaPostfxDefs::GetPostFXValue(PostFXType type)
3030
{
31-
switch (static_cast<int>(type))
31+
switch (type)
3232
{
33-
case 0: // Gamma
33+
case PostFXType::GAMMA:
3434
return g_pCore->GetCVars()->GetValue<float>("borderless_gamma_power", 0.0f);
35-
case 1: // Brightness
35+
case PostFXType::BRIGHTNESS:
3636
return g_pCore->GetCVars()->GetValue<float>("borderless_brightness_scale", 0.0f);
37-
case 2: // Contrast
37+
case PostFXType::CONTRAST:
3838
return g_pCore->GetCVars()->GetValue<float>("borderless_contrast_scale", 0.0f);
39-
case 3: // Saturation
39+
case PostFXType::SATURATION:
4040
return g_pCore->GetCVars()->GetValue<float>("borderless_saturation_scale", 0.0f);
41+
4142
default:
42-
return false;
43+
throw std::invalid_argument("Invalid PostFX type");
4344
}
4445
}
4546

@@ -50,19 +51,20 @@ int CLuaPostfxDefs::GetPostFXMode()
5051
: 0;
5152
}
5253

53-
bool CLuaPostfxDefs::IsPostFXEnabled(int type)
54+
bool CLuaPostfxDefs::IsPostFXEnabled(PostFXType type)
5455
{
55-
switch (static_cast<int>(type))
56+
switch (type)
5657
{
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);
58+
case PostFXType::GAMMA:
59+
return g_pCore->GetCVars()->GetValue<float>("borderless_gamma_enabled", false);
60+
case PostFXType::BRIGHTNESS:
61+
return g_pCore->GetCVars()->GetValue<float>("borderless_brightness_enabled", false);
62+
case PostFXType::CONTRAST:
63+
return g_pCore->GetCVars()->GetValue<float>("borderless_brightness_enabled", false);
64+
case PostFXType::SATURATION:
65+
return g_pCore->GetCVars()->GetValue<float>("borderless_saturation_enabled", false);
66+
6567
default:
66-
return false;
68+
throw std::invalid_argument("Invalid PostFX type");
6769
}
6870
}

Client/mods/deathmatch/logic/luadefs/CLuaPostfxDefs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class CLuaPostfxDefs : public CLuaDefs
1717
static void LoadFunctions();
1818

1919
private:
20-
static std::variant<float, bool> GetPostFXValue(int type);
20+
static float GetPostFXValue(PostFXType type);
2121
static int GetPostFXMode();
22-
static bool IsPostFXEnabled(int type);
22+
static bool IsPostFXEnabled(PostFXType type);
2323
};

Shared/sdk/enums/PostFXType.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/*****************************************************************************
2+
*
3+
* PROJECT: Multi Theft Auto
4+
* LICENSE: See LICENSE in the top level directory
5+
* FILE: sdk/PostFXType.h
6+
* PURPOSE: Header for common definitions
7+
*
8+
* Multi Theft Auto is available from https://www.multitheftauto.com/
9+
*
10+
*****************************************************************************/
11+
12+
enum class PostFXType
13+
{
14+
GAMMA,
15+
BRIGHTNESS,
16+
CONTRAST,
17+
SATURATION
18+
};

0 commit comments

Comments
 (0)