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