Skip to content

Commit

Permalink
Use maps for luadefs
Browse files Browse the repository at this point in the history
  • Loading branch information
qaisjp committed Sep 12, 2018
1 parent 4019806 commit 37e9336
Show file tree
Hide file tree
Showing 54 changed files with 1,991 additions and 1,559 deletions.
102 changes: 55 additions & 47 deletions Client/mods/deathmatch/logic/luadefs/CLuaAudioDefs.cpp
Expand Up @@ -13,53 +13,61 @@

void CLuaAudioDefs::LoadFunctions(void)
{
// Audio funcs
CLuaCFunctions::AddFunction("playSoundFrontEnd", PlaySoundFrontEnd);
CLuaCFunctions::AddFunction("setAmbientSoundEnabled", SetAmbientSoundEnabled);
CLuaCFunctions::AddFunction("isAmbientSoundEnabled", IsAmbientSoundEnabled);
CLuaCFunctions::AddFunction("resetAmbientSounds", ResetAmbientSounds);
CLuaCFunctions::AddFunction("setWorldSoundEnabled", SetWorldSoundEnabled);
CLuaCFunctions::AddFunction("isWorldSoundEnabled", IsWorldSoundEnabled);
CLuaCFunctions::AddFunction("resetWorldSounds", ResetWorldSounds);
CLuaCFunctions::AddFunction("playSFX", PlaySFX);
CLuaCFunctions::AddFunction("playSFX3D", PlaySFX3D);
CLuaCFunctions::AddFunction("getSFXStatus", GetSFXStatus);

// Sound effects and synth funcs
CLuaCFunctions::AddFunction("playSound", PlaySound);
CLuaCFunctions::AddFunction("playSound3D", PlaySound3D);
CLuaCFunctions::AddFunction("stopSound", StopSound);
CLuaCFunctions::AddFunction("setSoundPosition", SetSoundPosition);
CLuaCFunctions::AddFunction("getSoundPosition", GetSoundPosition);
CLuaCFunctions::AddFunction("getSoundLength", GetSoundLength);
CLuaCFunctions::AddFunction("setSoundPaused", SetSoundPaused);
CLuaCFunctions::AddFunction("isSoundPaused", IsSoundPaused);
CLuaCFunctions::AddFunction("setSoundVolume", SetSoundVolume);
CLuaCFunctions::AddFunction("getSoundVolume", GetSoundVolume);
CLuaCFunctions::AddFunction("setSoundSpeed", SetSoundSpeed);
CLuaCFunctions::AddFunction("getSoundSpeed", GetSoundSpeed);
CLuaCFunctions::AddFunction("setSoundProperties", SetSoundProperties);
CLuaCFunctions::AddFunction("getSoundProperties", GetSoundProperties);
CLuaCFunctions::AddFunction("getSoundFFTData", GetSoundFFTData);
CLuaCFunctions::AddFunction("getSoundWaveData", GetSoundWaveData);
CLuaCFunctions::AddFunction("getSoundLevelData", GetSoundLevelData);
CLuaCFunctions::AddFunction("getSoundBPM", GetSoundBPM);
CLuaCFunctions::AddFunction("setSoundPanningEnabled", SetSoundPanEnabled);
CLuaCFunctions::AddFunction("isSoundPanningEnabled", IsSoundPanEnabled);
CLuaCFunctions::AddFunction("setSoundMinDistance", SetSoundMinDistance);
CLuaCFunctions::AddFunction("getSoundMinDistance", GetSoundMinDistance);
CLuaCFunctions::AddFunction("setSoundMaxDistance", SetSoundMaxDistance);
CLuaCFunctions::AddFunction("getSoundMaxDistance", GetSoundMaxDistance);
CLuaCFunctions::AddFunction("getSoundMetaTags", GetSoundMetaTags);
CLuaCFunctions::AddFunction("setSoundEffectEnabled", SetSoundEffectEnabled);
CLuaCFunctions::AddFunction("getSoundEffects", GetSoundEffects);
CLuaCFunctions::AddFunction("setSoundPan", SetSoundPan);
CLuaCFunctions::AddFunction("getSoundPan", GetSoundPan);

// Radio funcs
CLuaCFunctions::AddFunction("setRadioChannel", SetRadioChannel);
CLuaCFunctions::AddFunction("getRadioChannel", GetRadioChannel);
CLuaCFunctions::AddFunction("getRadioChannelName", GetRadioChannelName);
std::map<const char*, lua_CFunction> functions{
// Audio funcs
{"playSoundFrontEnd", PlaySoundFrontEnd},
{"setAmbientSoundEnabled", SetAmbientSoundEnabled},
{"isAmbientSoundEnabled", IsAmbientSoundEnabled},
{"resetAmbientSounds", ResetAmbientSounds},
{"setWorldSoundEnabled", SetWorldSoundEnabled},
{"isWorldSoundEnabled", IsWorldSoundEnabled},
{"resetWorldSounds", ResetWorldSounds},
{"playSFX", PlaySFX},
{"playSFX3D", PlaySFX3D},
{"getSFXStatus", GetSFXStatus},

// Sound effects and synth funcs
{"playSound", PlaySound},
{"playSound3D", PlaySound3D},
{"stopSound", StopSound},
{"setSoundPosition", SetSoundPosition},
{"getSoundPosition", GetSoundPosition},
{"getSoundLength", GetSoundLength},
{"setSoundPaused", SetSoundPaused},
{"isSoundPaused", IsSoundPaused},
{"setSoundVolume", SetSoundVolume},
{"getSoundVolume", GetSoundVolume},
{"setSoundSpeed", SetSoundSpeed},
{"getSoundSpeed", GetSoundSpeed},
{"setSoundProperties", SetSoundProperties},
{"getSoundProperties", GetSoundProperties},
{"getSoundFFTData", GetSoundFFTData},
{"getSoundWaveData", GetSoundWaveData},
{"getSoundLevelData", GetSoundLevelData},
{"getSoundBPM", GetSoundBPM},
{"setSoundPanningEnabled", SetSoundPanEnabled},
{"isSoundPanningEnabled", IsSoundPanEnabled},
{"setSoundMinDistance", SetSoundMinDistance},
{"getSoundMinDistance", GetSoundMinDistance},
{"setSoundMaxDistance", SetSoundMaxDistance},
{"getSoundMaxDistance", GetSoundMaxDistance},
{"getSoundMetaTags", GetSoundMetaTags},
{"setSoundEffectEnabled", SetSoundEffectEnabled},
{"getSoundEffects", GetSoundEffects},
{"setSoundPan", SetSoundPan},
{"getSoundPan", GetSoundPan},

// Radio funcs
{"setRadioChannel", SetRadioChannel},
{"getRadioChannel", GetRadioChannel},
{"getRadioChannelName", GetRadioChannelName},
};

// Add functions
for (const auto& pair : functions)
{
CLuaCFunctions::AddFunction(pair.first, pair.second);
}
}

void CLuaAudioDefs::AddClass(lua_State* luaVM)
Expand Down
34 changes: 21 additions & 13 deletions Client/mods/deathmatch/logic/luadefs/CLuaBlipDefs.cpp
Expand Up @@ -13,19 +13,27 @@

void CLuaBlipDefs::LoadFunctions(void)
{
CLuaCFunctions::AddFunction("createBlip", CreateBlip);
CLuaCFunctions::AddFunction("createBlipAttachedTo", CreateBlipAttachedTo);
CLuaCFunctions::AddFunction("getBlipIcon", GetBlipIcon);
CLuaCFunctions::AddFunction("getBlipSize", GetBlipSize);
CLuaCFunctions::AddFunction("getBlipColor", GetBlipColor);
CLuaCFunctions::AddFunction("getBlipOrdering", GetBlipOrdering);
CLuaCFunctions::AddFunction("getBlipVisibleDistance", GetBlipVisibleDistance);

CLuaCFunctions::AddFunction("setBlipIcon", SetBlipIcon);
CLuaCFunctions::AddFunction("setBlipSize", SetBlipSize);
CLuaCFunctions::AddFunction("setBlipColor", SetBlipColor);
CLuaCFunctions::AddFunction("setBlipOrdering", SetBlipOrdering);
CLuaCFunctions::AddFunction("setBlipVisibleDistance", SetBlipVisibleDistance);
std::map<const char*, lua_CFunction> functions{
{"createBlip", CreateBlip},
{"createBlipAttachedTo", CreateBlipAttachedTo},
{"getBlipIcon", GetBlipIcon},
{"getBlipSize", GetBlipSize},
{"getBlipColor", GetBlipColor},
{"getBlipOrdering", GetBlipOrdering},
{"getBlipVisibleDistance", GetBlipVisibleDistance},

{"setBlipIcon", SetBlipIcon},
{"setBlipSize", SetBlipSize},
{"setBlipColor", SetBlipColor},
{"setBlipOrdering", SetBlipOrdering},
{"setBlipVisibleDistance", SetBlipVisibleDistance},
};

// Add functions
for (const auto& pair : functions)
{
CLuaCFunctions::AddFunction(pair.first, pair.second);
}
}

void CLuaBlipDefs::AddClass(lua_State* luaVM)
Expand Down
50 changes: 29 additions & 21 deletions Client/mods/deathmatch/logic/luadefs/CLuaCameraDefs.cpp
Expand Up @@ -14,27 +14,35 @@

void CLuaCameraDefs::LoadFunctions(void)
{
// Cam get funcs
CLuaCFunctions::AddFunction("getCamera", GetCamera);
CLuaCFunctions::AddFunction("getCameraViewMode", GetCameraViewMode);
CLuaCFunctions::AddFunction("getCameraMatrix", GetCameraMatrix);
CLuaCFunctions::AddFunction("getCameraTarget", GetCameraTarget);
CLuaCFunctions::AddFunction("getCameraInterior", GetCameraInterior);
CLuaCFunctions::AddFunction("getCameraGoggleEffect", GetCameraGoggleEffect);
CLuaCFunctions::AddFunction("getCameraShakeLevel", GetCameraShakeLevel);
CLuaCFunctions::AddFunction("getCameraFieldOfView", GetCameraFieldOfView);

// Cam set funcs
CLuaCFunctions::AddFunction("setCameraMatrix", SetCameraMatrix);
CLuaCFunctions::AddFunction("setCameraFieldOfView", SetCameraFieldOfView);
CLuaCFunctions::AddFunction("setCameraTarget", SetCameraTarget);
CLuaCFunctions::AddFunction("setCameraInterior", SetCameraInterior);
CLuaCFunctions::AddFunction("fadeCamera", FadeCamera);
CLuaCFunctions::AddFunction("setCameraClip", SetCameraClip);
CLuaCFunctions::AddFunction("getCameraClip", GetCameraClip);
CLuaCFunctions::AddFunction("setCameraViewMode", SetCameraViewMode);
CLuaCFunctions::AddFunction("setCameraGoggleEffect", SetCameraGoggleEffect);
CLuaCFunctions::AddFunction("setCameraShakeLevel", SetCameraShakeLevel);
std::map<const char*, lua_CFunction> functions{
// Cam get funcs
{"getCamera", GetCamera},
{"getCameraViewMode", GetCameraViewMode},
{"getCameraMatrix", GetCameraMatrix},
{"getCameraTarget", GetCameraTarget},
{"getCameraInterior", GetCameraInterior},
{"getCameraGoggleEffect", GetCameraGoggleEffect},
{"getCameraShakeLevel", GetCameraShakeLevel},
{"getCameraFieldOfView", GetCameraFieldOfView},

// Cam set funcs
{"setCameraMatrix", SetCameraMatrix},
{"setCameraFieldOfView", SetCameraFieldOfView},
{"setCameraTarget", SetCameraTarget},
{"setCameraInterior", SetCameraInterior},
{"fadeCamera", FadeCamera},
{"setCameraClip", SetCameraClip},
{"getCameraClip", GetCameraClip},
{"setCameraViewMode", SetCameraViewMode},
{"setCameraGoggleEffect", SetCameraGoggleEffect},
{"setCameraShakeLevel", SetCameraShakeLevel},
};

// Add functions
for (const auto& pair : functions)
{
CLuaCFunctions::AddFunction(pair.first, pair.second);
}
}

void CLuaCameraDefs::AddClass(lua_State* luaVM)
Expand Down
26 changes: 17 additions & 9 deletions Client/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.cpp
Expand Up @@ -13,15 +13,23 @@

void CLuaColShapeDefs::LoadFunctions(void)
{
CLuaCFunctions::AddFunction("createColCircle", CreateColCircle);
CLuaCFunctions::AddFunction("createColCuboid", CreateColCuboid);
CLuaCFunctions::AddFunction("createColSphere", CreateColSphere);
CLuaCFunctions::AddFunction("createColRectangle", CreateColRectangle);
CLuaCFunctions::AddFunction("createColPolygon", CreateColPolygon);
CLuaCFunctions::AddFunction("createColTube", CreateColTube);

CLuaCFunctions::AddFunction("isInsideColShape", IsInsideColShape);
CLuaCFunctions::AddFunction("getColShapeType", GetColShapeType);
std::map<const char*, lua_CFunction> functions{
{"createColCircle", CreateColCircle},
{"createColCuboid", CreateColCuboid},
{"createColSphere", CreateColSphere},
{"createColRectangle", CreateColRectangle},
{"createColPolygon", CreateColPolygon},
{"createColTube", CreateColTube},

{"isInsideColShape", IsInsideColShape},
{"getColShapeType", GetColShapeType},
};

// Add functions
for (const auto& pair : functions)
{
CLuaCFunctions::AddFunction(pair.first, pair.second);
}
}

void CLuaColShapeDefs::AddClass(lua_State* luaVM)
Expand Down
84 changes: 46 additions & 38 deletions Client/mods/deathmatch/logic/luadefs/CLuaDrawingDefs.cpp
Expand Up @@ -15,44 +15,52 @@ extern bool g_bAllowAspectRatioAdjustment;

void CLuaDrawingDefs::LoadFunctions(void)
{
CLuaCFunctions::AddFunction("dxDrawLine", DxDrawLine);
CLuaCFunctions::AddFunction("dxDrawMaterialLine3D", DxDrawMaterialLine3D);
CLuaCFunctions::AddFunction("dxDrawMaterialSectionLine3D", DxDrawMaterialSectionLine3D);
CLuaCFunctions::AddFunction("dxDrawLine3D", DxDrawLine3D);
CLuaCFunctions::AddFunction("dxDrawText", DxDrawText);
CLuaCFunctions::AddFunction("dxDrawRectangle", DxDrawRectangle);
CLuaCFunctions::AddFunction("dxDrawCircle", DxDrawCircle);
CLuaCFunctions::AddFunction("dxDrawImage", DxDrawImage);
CLuaCFunctions::AddFunction("dxDrawImageSection", DxDrawImageSection);
CLuaCFunctions::AddFunction("dxDrawPrimitive", DxDrawPrimitive);
CLuaCFunctions::AddFunction("dxDrawMaterialPrimitive", DxDrawMaterialPrimitive);
CLuaCFunctions::AddFunction("dxGetTextWidth", DxGetTextWidth);
CLuaCFunctions::AddFunction("dxGetFontHeight", DxGetFontHeight);
CLuaCFunctions::AddFunction("dxCreateFont", DxCreateFont);
CLuaCFunctions::AddFunction("dxCreateTexture", DxCreateTexture);
CLuaCFunctions::AddFunction("dxCreateShader", DxCreateShader);
CLuaCFunctions::AddFunction("dxCreateRenderTarget", DxCreateRenderTarget);
CLuaCFunctions::AddFunction("dxCreateScreenSource", DxCreateScreenSource);
CLuaCFunctions::AddFunction("dxGetMaterialSize", DxGetMaterialSize);
CLuaCFunctions::AddFunction("dxSetShaderValue", DxSetShaderValue);
CLuaCFunctions::AddFunction("dxSetShaderTessellation", DxSetShaderTessellation);
CLuaCFunctions::AddFunction("dxSetShaderTransform", DxSetShaderTransform);
CLuaCFunctions::AddFunction("dxSetRenderTarget", DxSetRenderTarget);
CLuaCFunctions::AddFunction("dxUpdateScreenSource", DxUpdateScreenSource);
CLuaCFunctions::AddFunction("dxGetStatus", DxGetStatus);
CLuaCFunctions::AddFunction("dxSetTestMode", DxSetTestMode);
CLuaCFunctions::AddFunction("dxGetTexturePixels", DxGetTexturePixels);
CLuaCFunctions::AddFunction("dxSetTexturePixels", DxSetTexturePixels);
CLuaCFunctions::AddFunction("dxGetPixelsSize", DxGetPixelsSize);
CLuaCFunctions::AddFunction("dxGetPixelsFormat", DxGetPixelsFormat);
CLuaCFunctions::AddFunction("dxConvertPixels", DxConvertPixels);
CLuaCFunctions::AddFunction("dxGetPixelColor", DxGetPixelColor);
CLuaCFunctions::AddFunction("dxSetPixelColor", DxSetPixelColor);
CLuaCFunctions::AddFunction("dxSetBlendMode", DxSetBlendMode);
CLuaCFunctions::AddFunction("dxGetBlendMode", DxGetBlendMode);
CLuaCFunctions::AddFunction("dxSetAspectRatioAdjustmentEnabled", DxSetAspectRatioAdjustmentEnabled);
CLuaCFunctions::AddFunction("dxIsAspectRatioAdjustmentEnabled", DxIsAspectRatioAdjustmentEnabled);
CLuaCFunctions::AddFunction("dxSetTextureEdge", DxSetTextureEdge);
std::map<const char*, lua_CFunction> functions{
{"dxDrawLine", DxDrawLine},
{"dxDrawMaterialLine3D", DxDrawMaterialLine3D},
{"dxDrawMaterialSectionLine3D", DxDrawMaterialSectionLine3D},
{"dxDrawLine3D", DxDrawLine3D},
{"dxDrawText", DxDrawText},
{"dxDrawRectangle", DxDrawRectangle},
{"dxDrawCircle", DxDrawCircle},
{"dxDrawImage", DxDrawImage},
{"dxDrawImageSection", DxDrawImageSection},
{"dxDrawPrimitive", DxDrawPrimitive},
{"dxDrawMaterialPrimitive", DxDrawMaterialPrimitive},
{"dxGetTextWidth", DxGetTextWidth},
{"dxGetFontHeight", DxGetFontHeight},
{"dxCreateFont", DxCreateFont},
{"dxCreateTexture", DxCreateTexture},
{"dxCreateShader", DxCreateShader},
{"dxCreateRenderTarget", DxCreateRenderTarget},
{"dxCreateScreenSource", DxCreateScreenSource},
{"dxGetMaterialSize", DxGetMaterialSize},
{"dxSetShaderValue", DxSetShaderValue},
{"dxSetShaderTessellation", DxSetShaderTessellation},
{"dxSetShaderTransform", DxSetShaderTransform},
{"dxSetRenderTarget", DxSetRenderTarget},
{"dxUpdateScreenSource", DxUpdateScreenSource},
{"dxGetStatus", DxGetStatus},
{"dxSetTestMode", DxSetTestMode},
{"dxGetTexturePixels", DxGetTexturePixels},
{"dxSetTexturePixels", DxSetTexturePixels},
{"dxGetPixelsSize", DxGetPixelsSize},
{"dxGetPixelsFormat", DxGetPixelsFormat},
{"dxConvertPixels", DxConvertPixels},
{"dxGetPixelColor", DxGetPixelColor},
{"dxSetPixelColor", DxSetPixelColor},
{"dxSetBlendMode", DxSetBlendMode},
{"dxGetBlendMode", DxGetBlendMode},
{"dxSetAspectRatioAdjustmentEnabled", DxSetAspectRatioAdjustmentEnabled},
{"dxIsAspectRatioAdjustmentEnabled", DxIsAspectRatioAdjustmentEnabled},
{"dxSetTextureEdge", DxSetTextureEdge},
};

// Add functions
for (const auto& pair : functions)
{
CLuaCFunctions::AddFunction(pair.first, pair.second);
}
}

void CLuaDrawingDefs::AddClass(lua_State* luaVM)
Expand Down
46 changes: 27 additions & 19 deletions Client/mods/deathmatch/logic/luadefs/CLuaEffectDefs.cpp
Expand Up @@ -13,25 +13,33 @@

void CLuaEffectDefs::LoadFunctions(void)
{
CLuaCFunctions::AddFunction("fxAddBlood", fxAddBlood);
CLuaCFunctions::AddFunction("fxAddWood", fxAddWood);
CLuaCFunctions::AddFunction("fxAddSparks", fxAddSparks);
CLuaCFunctions::AddFunction("fxAddTyreBurst", fxAddTyreBurst);
CLuaCFunctions::AddFunction("fxAddBulletImpact", fxAddBulletImpact);
CLuaCFunctions::AddFunction("fxAddPunchImpact", fxAddPunchImpact);
CLuaCFunctions::AddFunction("fxAddDebris", fxAddDebris);
CLuaCFunctions::AddFunction("fxAddGlass", fxAddGlass);
CLuaCFunctions::AddFunction("fxAddWaterHydrant", fxAddWaterHydrant);
CLuaCFunctions::AddFunction("fxAddGunshot", fxAddGunshot);
CLuaCFunctions::AddFunction("fxAddTankFire", fxAddTankFire);
CLuaCFunctions::AddFunction("fxAddWaterSplash", fxAddWaterSplash);
CLuaCFunctions::AddFunction("fxAddBulletSplash", fxAddBulletSplash);
CLuaCFunctions::AddFunction("fxAddFootSplash", fxAddFootSplash);
CLuaCFunctions::AddFunction("createEffect", CreateEffect);
CLuaCFunctions::AddFunction("setEffectSpeed", SetEffectSpeed);
CLuaCFunctions::AddFunction("getEffectSpeed", GetEffectSpeed);
CLuaCFunctions::AddFunction("setEffectDensity", SetEffectDensity);
CLuaCFunctions::AddFunction("getEffectDensity", GetEffectDensity);
std::map<const char*, lua_CFunction> functions{
{"fxAddBlood", fxAddBlood},
{"fxAddWood", fxAddWood},
{"fxAddSparks", fxAddSparks},
{"fxAddTyreBurst", fxAddTyreBurst},
{"fxAddBulletImpact", fxAddBulletImpact},
{"fxAddPunchImpact", fxAddPunchImpact},
{"fxAddDebris", fxAddDebris},
{"fxAddGlass", fxAddGlass},
{"fxAddWaterHydrant", fxAddWaterHydrant},
{"fxAddGunshot", fxAddGunshot},
{"fxAddTankFire", fxAddTankFire},
{"fxAddWaterSplash", fxAddWaterSplash},
{"fxAddBulletSplash", fxAddBulletSplash},
{"fxAddFootSplash", fxAddFootSplash},
{"createEffect", CreateEffect},
{"setEffectSpeed", SetEffectSpeed},
{"getEffectSpeed", GetEffectSpeed},
{"setEffectDensity", SetEffectDensity},
{"getEffectDensity", GetEffectDensity},
};

// Add functions
for (const auto& pair : functions)
{
CLuaCFunctions::AddFunction(pair.first, pair.second);
}
}

void CLuaEffectDefs::AddClass(lua_State* luaVM)
Expand Down

0 comments on commit 37e9336

Please sign in to comment.