feat: Added Sky class
+ changed file structure in the python module + fixed static method binding for PyDaedalus class
This commit is contained in:
21
src/bind.cpp
21
src/bind.cpp
@@ -3,6 +3,7 @@
|
||||
#include "classes/py/DamageDescription.h"
|
||||
#include "classes/py/ItemGround.h"
|
||||
#include "classes/py/Daedalus.h"
|
||||
#include "classes/py/Sky.h"
|
||||
#include <NoNut/core/Constant.h>
|
||||
|
||||
namespace py = pybind11;
|
||||
@@ -68,7 +69,21 @@ PYBIND11_EMBEDDED_MODULE(sqg2o, m) {
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PyDaedalus>(m, "Daedalus")
|
||||
.def_static("index", &PyDaedalus::index)
|
||||
.def_static("symbol", &PyDaedalus::symbol)
|
||||
.def_static("instance", &PyDaedalus::instance);
|
||||
.def_static("index", [](std::string value){ return PyDaedalus::index(value); })
|
||||
.def_static("symbol", [](std::string value){ return PyDaedalus::symbol(value); })
|
||||
.def_static("instance", [](std::string value){ return PyDaedalus::instance(value); });
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
py::class_<PySky>(m, "Sky")
|
||||
.def_property_static("weather", [](py::object){ return PySky::getWeather(); }, [](py::object, int value) { PySky::setWeather(value); })
|
||||
.def_property_static("raining", [](py::object){ return PySky::getRaining(); }, [](py::object, int value) { PySky::setRaining(value); })
|
||||
.def_property_static("renderLightning", [](py::object){ return PySky::getRenderLightning(); }, [](py::object, int value) { PySky::setRenderLightning(value); })
|
||||
.def_property_static("windScale", [](py::object){ return PySky::getWindScale(); }, [](py::object, int value) { PySky::setWindScale(value); })
|
||||
.def_property_static("dontRain", [](py::object){ return PySky::getDontRain(); }, [](py::object, int value) { PySky::setDontRain(value); })
|
||||
|
||||
.def_static("setRainStartTime", [](int hour, int min){ return PySky::setRainStartTime(hour, min); })
|
||||
.def_static("setRainStopTime", [](int hour, int min){ return PySky::setRainStopTime(hour, min); })
|
||||
.def_static("getRainStartTime", [](){ return PySky::getRainStartTime(); })
|
||||
.def_static("getRainStopTime", [](){ return PySky::getRainStopTime(); });
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <classes/sq/Daedalus.h>
|
||||
#include <pybind11/embed.h>
|
||||
#include <iostream>
|
||||
namespace py = pybind11;
|
||||
|
||||
class PyDaedalus
|
||||
@@ -11,8 +10,7 @@ class PyDaedalus
|
||||
|
||||
public:
|
||||
|
||||
//static nonut::Int index(nonut::String value) { return nonut::Daedalus::get()->index(value); }
|
||||
static nonut::Int index(nonut::String value) { std::cout << nonut::Daedalus::get()->index(value) << std::endl;return 5; }
|
||||
static nonut::Int index(nonut::String value) { return nonut::Daedalus::get()->index(value); }
|
||||
static py::dict symbol(nonut::String value) { return nonut::Daedalus::get()->symbol(value).data; }
|
||||
static py::dict instance(nonut::String value) { return nonut::Daedalus::get()->instance(value).data; }
|
||||
};
|
||||
|
||||
30
src/classes/py/Sky.h
Normal file
30
src/classes/py/Sky.h
Normal file
@@ -0,0 +1,30 @@
|
||||
#ifndef _PYSKY_H_
|
||||
#define _PYSKY_H_
|
||||
|
||||
#include <classes/sq/Sky.h>
|
||||
#include <pybind11/embed.h>
|
||||
namespace py = pybind11;
|
||||
|
||||
class PySky
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static void setWeather(nonut::Int value) { nonut::Sky::get()->weather = value; }
|
||||
static nonut::Int getWeather() { return nonut::Sky::get()->weather; }
|
||||
static void setRaining(nonut::Bool value) { nonut::Sky::get()->raining = value; }
|
||||
static nonut::Bool getRaining() { return nonut::Sky::get()->raining; }
|
||||
static void setRenderLightning(nonut::Bool value) { nonut::Sky::get()->renderLightning = value; }
|
||||
static nonut::Bool getRenderLightning() { return nonut::Sky::get()->renderLightning; }
|
||||
static void setWindScale(nonut::Float value) { nonut::Sky::get()->windScale = value; }
|
||||
static nonut::Float getWindScale() { return nonut::Sky::get()->windScale; }
|
||||
static void setDontRain(nonut::Bool value) { nonut::Sky::get()->dontRain = value; }
|
||||
static nonut::Bool getDontRain() { return nonut::Sky::get()->dontRain; }
|
||||
|
||||
static void setRainStartTime(nonut::Int h, nonut::Int m) { nonut::Sky::get()->setRainStartTime(h, m); }
|
||||
static void setRainStopTime(nonut::Int h, nonut::Int m) { nonut::Sky::get()->setRainStopTime(h, m); }
|
||||
static py::dict getRainStartTime() { return nonut::Sky::get()->getRainStartTime().data; }
|
||||
static py::dict getRainStopTime() { return nonut::Sky::get()->getRainStopTime().data; }
|
||||
};
|
||||
|
||||
#endif
|
||||
30
src/classes/sq/Sky.cpp
Normal file
30
src/classes/sq/Sky.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <NoNut/core/CommonHeader.h>
|
||||
#include "Sky.h"
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
Sky* Sky::get()
|
||||
{
|
||||
if (inst == nullptr)
|
||||
{
|
||||
inst = new Sky();
|
||||
}
|
||||
return inst;
|
||||
}
|
||||
|
||||
Sky::Sky() :
|
||||
StaticClass("Sky"),
|
||||
|
||||
PROPERTY_CTOR(weather),
|
||||
PROPERTY_CTOR(raining),
|
||||
PROPERTY_CTOR(renderLightning),
|
||||
PROPERTY_CTOR(windScale),
|
||||
PROPERTY_CTOR(dontRain),
|
||||
|
||||
METHOD_CTOR(getRainStartTime),
|
||||
METHOD_CTOR(getRainStopTime),
|
||||
METHOD_CTOR(setRainStartTime),
|
||||
METHOD_CTOR(setRainStopTime)
|
||||
{
|
||||
}
|
||||
}
|
||||
34
src/classes/sq/Sky.h
Normal file
34
src/classes/sq/Sky.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#ifndef _SKY_H_
|
||||
#define _SKY_H_
|
||||
#include <string>
|
||||
|
||||
#include <NoNut/core/StaticClass.h>
|
||||
#include <NoNut/core/CustomTypes.h>
|
||||
|
||||
namespace nonut
|
||||
{
|
||||
class Sky : public StaticClass
|
||||
{
|
||||
public:
|
||||
static Sky* get();
|
||||
|
||||
Function<void, Int, Int> setRainStartTime;
|
||||
Function<SqDict> getRainStartTime;
|
||||
Function<void, Int, Int> setRainStopTime;
|
||||
Function<SqDict> getRainStopTime;
|
||||
|
||||
Property<Int> weather;
|
||||
Property<Bool> raining;
|
||||
Property<Bool> renderLightning;
|
||||
Property<Float> windScale;
|
||||
Property<Bool> dontRain;
|
||||
|
||||
private:
|
||||
|
||||
static inline Sky* inst = nullptr;
|
||||
|
||||
Sky();
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user