1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
#include "MapInterface.h"
#include <pybind11/pybind11.h>
#include "imap.h"
namespace script
{
ScriptSceneNode MapInterface::getWorldSpawn()
{
return ScriptSceneNode(GlobalMapModule().getWorldspawn());
}
std::string MapInterface::getMapName()
{
return GlobalMapModule().getMapName();
}
IMap::EditMode MapInterface::getEditMode()
{
return GlobalMapModule().getEditMode();
}
void MapInterface::setEditMode(IMap::EditMode mode)
{
GlobalMapModule().setEditMode(mode);
}
ScriptSceneNode MapInterface::getRoot()
{
return ScriptSceneNode(GlobalMapModule().getRoot());
}
bool MapInterface::isModified()
{
return GlobalMapModule().isModified();
}
void MapInterface::showPointFile(const std::string& filePath)
{
if (!filePath.empty())
{
GlobalMapModule().showPointFile(filePath);
}
}
bool MapInterface::isPointTraceVisible()
{
return GlobalMapModule().isPointTraceVisible();
}
std::vector<std::string> MapInterface::getPointFileList()
{
std::vector<std::string> files;
GlobalMapModule().forEachPointfile([&](const fs::path& path)
{
files.push_back(path.string());
});
return files;
}
// IScriptInterface implementation
void MapInterface::registerInterface(py::module& scope, py::dict& globals)
{
// Add the module declaration to the given python namespace
py::class_<MapInterface> map(scope, "Map");
// Expose the edit mode enum
py::enum_<IMap::EditMode>(scope, "MapEditMode")
.value("Normal", IMap::EditMode::Normal)
.value("Merge", IMap::EditMode::Merge)
.export_values();
map.def("getWorldSpawn", &MapInterface::getWorldSpawn);
map.def("getMapName", &MapInterface::getMapName);
map.def("getRoot", &MapInterface::getRoot);
map.def("isModified", &MapInterface::isModified);
map.def("getEditMode", &MapInterface::getEditMode);
map.def("setEditMode", &MapInterface::setEditMode);
map.def("showPointFile", &MapInterface::showPointFile);
map.def("isPointTraceVisible", &MapInterface::isPointTraceVisible);
map.def("getPointFileList", &MapInterface::getPointFileList);
// Now point the Python variable "GlobalMap" to this instance
globals["GlobalMap"] = this;
}
} // namespace script
|