-
-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70809d5
commit 5af6b06
Showing
8 changed files
with
137 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: mods/shared_logic/luadefs/CLuaModelDefs.cpp | ||
* PURPOSE: Lua model definitions class | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#include "StdInc.h" | ||
#include <lua/CLuaFunctionParser.h> | ||
#include "CLodModels.h" | ||
#include "CClientObjectManager.h" | ||
#include "CClientBuildingManager.h" | ||
|
||
void CLuaModelDefs::LoadFunctions() | ||
{ | ||
constexpr static const std::pair<const char*, lua_CFunction> functions[]{ | ||
// Util func | ||
{"IsValidModel", ArgumentParser<IsValidModel>}, | ||
|
||
// LOD funcs | ||
{"getLowLODModel", ArgumentParser<GetLowLODModel>}, | ||
{"getHighLODModel", ArgumentParser<GetHighLODModel>}, | ||
{"setLowLODModel", ArgumentParser<SetLowLODModel>}, | ||
{"resetLowLODModel", ArgumentParser<ResetLowLODModel>}, | ||
{"resetLowLODModels", ArgumentParser<ResetLowLODModels>}, | ||
}; | ||
|
||
// Add functions | ||
for (const auto& [name, func] : functions) | ||
CLuaCFunctions::AddFunction(name, func); | ||
} | ||
|
||
|
||
bool CLuaModelDefs::IsValidModel(std::string modelPurpose, std::uint32_t id) | ||
{ | ||
if (modelPurpose == "object") | ||
return CClientObjectManager::IsValidModel(id); | ||
else if (modelPurpose == "building") | ||
return CClientBuildingManager::IsValidModel(id); | ||
|
||
throw std::invalid_argument("Invalid model purpose passed, expected 'object' or 'building'"); | ||
} | ||
|
||
std::variant<bool, std::uint32_t> CLuaModelDefs::GetLowLODModel(std::uint32_t hLODModel) noexcept | ||
{ | ||
return CLodModels::GetLowLODModel(hLODModel); | ||
} | ||
|
||
std::variant<bool, std::uint32_t> CLuaModelDefs::GetHighLODModel(std::uint32_t lLODModel) noexcept | ||
{ | ||
return CLodModels::GetHighLODModel(lLODModel); | ||
} | ||
|
||
bool CLuaModelDefs::SetLowLODModel(std::string modelPurpose, std::uint32_t hLODModel, std::uint32_t lLODModel) | ||
{ | ||
if (!IsValidModel(modelPurpose, hLODModel)) | ||
throw std::invalid_argument("Invalid model ID passed for High-LOD argument"); | ||
|
||
if (!IsValidModel(modelPurpose, lLODModel)) | ||
throw std::invalid_argument("Invalid model ID passed for Low-LOD argument"); | ||
|
||
return CLodModels::SetLowLODModel(hLODModel, lLODModel); | ||
} | ||
|
||
bool CLuaModelDefs::ResetLowLODModel(std::uint32_t hLODModel) noexcept | ||
{ | ||
return CLodModels::ResetLowLODModel(hLODModel); | ||
} | ||
|
||
void CLuaModelDefs::ResetLowLODModels() noexcept | ||
{ | ||
CLodModels::ResetLowLODModels(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/***************************************************************************** | ||
* | ||
* PROJECT: Multi Theft Auto | ||
* LICENSE: See LICENSE in the top level directory | ||
* FILE: mods/shared_logic/luadefs/CLuaModelDefs.h | ||
* PURPOSE: Lua model definitions class header | ||
* | ||
* Multi Theft Auto is available from http://www.multitheftauto.com/ | ||
* | ||
*****************************************************************************/ | ||
|
||
#pragma once | ||
#include "CLuaDefs.h" | ||
|
||
class CLuaModelDefs : public CLuaDefs | ||
{ | ||
public: | ||
static void LoadFunctions(); | ||
|
||
// Util func | ||
static bool IsValidModel(std::string modelPurpose, std::uint32_t id); | ||
|
||
// LOD funcs | ||
static std::variant<bool, std::uint32_t> GetLowLODModel(std::uint32_t hLODModel) noexcept; | ||
static std::variant<bool, std::uint32_t> GetHighLODModel(std::uint32_t lLODModel) noexcept; | ||
static bool SetLowLODModel(std::string modelPurpose, std::uint32_t hLODModel, std::uint32_t lLODModel); | ||
static bool ResetLowLODModel(std::uint32_t hLODModel) noexcept; | ||
static void ResetLowLODModels() noexcept; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters