feat: Added Way class
This commit is contained in:
13
src/bind.cpp
13
src/bind.cpp
@@ -7,6 +7,7 @@
|
||||
#include "classes/py/Sky.h"
|
||||
#include "classes/py/ItemsGround.h"
|
||||
#include "classes/py/Mds.h"
|
||||
#include "classes/py/Way.h"
|
||||
|
||||
#include "functions/pyfunctions.h"
|
||||
|
||||
@@ -108,6 +109,18 @@ PYBIND11_EMBEDDED_MODULE(sqg2o, m) {
|
||||
.def_static("id", [](std::string value){ return PyMds::id(value); })
|
||||
.def_static("name", [](int value){ return PyMds::name(value); });
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PyWay>(m, "Way")
|
||||
|
||||
.def(py::init<std::string, std::string, std::string>())
|
||||
.def("getWaypoints", &PyWay::getWaypoints)
|
||||
.def("getCountWaypoints", &PyWay::getCountWaypoints)
|
||||
.def("__del__", &PyWay::del)
|
||||
|
||||
.def_property_readonly("start", &PyWay::getStart)
|
||||
.def_property_readonly("end", &PyWay::getEnd);
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
m.def("getHostname", &py_getHostname);
|
||||
|
||||
24
src/classes/py/Way.h
Normal file
24
src/classes/py/Way.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _PYWAY_H_
|
||||
#define _PYWAY_H_
|
||||
|
||||
#include <classes/sq/Way.h>
|
||||
|
||||
class PyWay
|
||||
{
|
||||
private:
|
||||
nonut::Way *sqway;
|
||||
|
||||
public:
|
||||
PyWay(std::string world, std::string start, std::string end) { sqway = new nonut::Way(world, start, end); };
|
||||
PyWay(SQObject obj) { if (obj._type == OT_NULL) throw py::type_error("Presented Squirrel Object doesn't exist (type: null)"); sqway = new nonut::Way(obj); }
|
||||
|
||||
py::list getWaypoints() { return sqway->getWaypoints().data; }
|
||||
int getCountWaypoints() { return sqway->getCountWaypoints(); }
|
||||
|
||||
std::string getStart() { return sqway->start; }
|
||||
std::string getEnd() { return sqway->end; }
|
||||
|
||||
void del() { delete sqway; }
|
||||
};
|
||||
|
||||
#endif
|
||||
26
src/classes/sq/Way.cpp
Normal file
26
src/classes/sq/Way.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
#include <NoNut/core/CommonHeader.h>
|
||||
#include "Way.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
Way::Way(String world, String startWp, String endWp) :
|
||||
Class("Way"),
|
||||
METHOD_CTOR(getWaypoints),
|
||||
METHOD_CTOR(getCountWaypoints),
|
||||
|
||||
PROPERTY_CTOR(start),
|
||||
PROPERTY_CTOR(end)
|
||||
{
|
||||
classCtor(world, startWp, endWp);
|
||||
}
|
||||
|
||||
Way::Way(SQObject object) :
|
||||
Class("Way", object),
|
||||
METHOD_CTOR(getWaypoints),
|
||||
METHOD_CTOR(getCountWaypoints),
|
||||
|
||||
PROPERTY_CTOR(start),
|
||||
PROPERTY_CTOR(end)
|
||||
{
|
||||
}
|
||||
}
|
||||
24
src/classes/sq/Way.h
Normal file
24
src/classes/sq/Way.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef _WAY_H
|
||||
#define _WAY_H
|
||||
#include <string>
|
||||
|
||||
#include <NoNut/core/Class.h>
|
||||
#include <NoNut/core/CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Way : public Class
|
||||
{
|
||||
public:
|
||||
Way(String, String, String);
|
||||
explicit Way(SQObject object);
|
||||
|
||||
Property<String> start;
|
||||
Property<String> end;
|
||||
|
||||
Function<SqList> getWaypoints;
|
||||
Function<Int> getCountWaypoints;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user