Skip to content
Snippets Groups Projects
Commit d1704107 authored by David Bergström's avatar David Bergström
Browse files

Add white as default argument to draw functions

parent 0a2c839f
No related branches found
No related tags found
No related merge requests found
#include "library.h"
namespace py = pybind11;
void define_color(py::module & m)
{
py::class_<sc2::Color> color(m, "Color");
color.def(py::init<>());
color.def(py::init<int, int, int>(), "r"_a, "g"_a, "b"_a);
color.def_readwrite("r", &sc2::Color::r, "Red");
color.def_readwrite("g", &sc2::Color::g, "Green");
color.def_readwrite("b", &sc2::Color::b, "Blue");
color.attr("WHITE") = sc2::Colors::White;
color.attr("RED") = sc2::Colors::Red;
color.attr("GREEN") = sc2::Colors::Green;
color.attr("YELLOW") = sc2::Colors::Yellow;
color.attr("BLUE") = sc2::Colors::Blue;
color.attr("TEAL") = sc2::Colors::Teal;
color.attr("PURPLE") = sc2::Colors::Purple;
color.attr("BLACK") = sc2::Colors::Black;
color.attr("GRAY") = sc2::Colors::Gray;
}
\ No newline at end of file
...@@ -9,12 +9,11 @@ void define_map_tools(py::module & m) ...@@ -9,12 +9,11 @@ void define_map_tools(py::module & m)
.def_property_readonly("width", &MapTools::width, "The width of the map") .def_property_readonly("width", &MapTools::width, "The width of the map")
.def_property_readonly("height", &MapTools::height, "The height of the map") .def_property_readonly("height", &MapTools::height, "The height of the map")
//.def("terrainHeight", &MapTools::terrainHeight, py::const_) //.def("terrainHeight", &MapTools::terrainHeight, py::const_)
.def("draw_line", py::overload_cast<const CCPosition &, const CCPosition &, const CCColor &>(&MapTools::drawLine, py::const_), py::arg("start"), py::arg("stop"), py::arg("color")) .def("draw_line", py::overload_cast<const CCPosition &, const CCPosition &, const CCColor &>(&MapTools::drawLine, py::const_), py::arg("start"), py::arg("stop"), py::arg("color") = white)
//.def("draw_line", py::overload_cast<CCPositionType, CCPositionType, CCPositionType, CCPositionType, const CCColor &>(&MapTools::drawLine, py::const_)); // TODO: Default argument?? .def("draw_box", py::overload_cast<const CCPosition &, const CCPosition &, const CCColor &>(&MapTools::drawBox, py::const_), py::arg("top_left"), py::arg("bottom_right"), py::arg("color") = white)
.def("draw_box", py::overload_cast<const CCPosition &, const CCPosition &, const CCColor &>(&MapTools::drawBox, py::const_), py::arg("top_left"), py::arg("bottom_right"), py::arg("color")) .def("draw_circle", py::overload_cast<const CCPosition &, CCPositionType, const CCColor &>(&MapTools::drawCircle, py::const_), py::arg("center"), py::arg("radius"), py::arg("color") = white)
.def("draw_circle", py::overload_cast<const CCPosition &, CCPositionType, const CCColor &>(&MapTools::drawCircle, py::const_), py::arg("center"), py::arg("radius"), py::arg("color")) .def("draw_text", &MapTools::drawText, "position"_a, "text"_a, "color"_a = white)
.def("draw_text", &MapTools::drawText, "position"_a, "text"_a, "color"_a) .def("draw_text_screen", &MapTools::drawTextScreen, "percentage_x"_a, "percentage_y"_a, "text"_a, "color"_a = white);
.def("draw_text_screen", &MapTools::drawTextScreen, "percentage_x"_a, "percentage_y"_a, "text"_a, "color"_a);
/* /*
TODO: Left to implement TODO: Left to implement
......
...@@ -13,6 +13,7 @@ PYBIND11_MODULE(library, m) ...@@ -13,6 +13,7 @@ PYBIND11_MODULE(library, m)
define_point(m); define_point(m);
define_base_location(m); define_base_location(m);
define_tech_tree(m); define_tech_tree(m);
define_color(m);
define_map_tools(m); define_map_tools(m);
define_building_placer(m); define_building_placer(m);
...@@ -89,22 +90,6 @@ PYBIND11_MODULE(library, m) ...@@ -89,22 +90,6 @@ PYBIND11_MODULE(library, m)
.value("CheatMoney", sc2::Difficulty::CheatMoney) .value("CheatMoney", sc2::Difficulty::CheatMoney)
.value("CheatInsane", sc2::Difficulty::CheatInsane); .value("CheatInsane", sc2::Difficulty::CheatInsane);
py::class_<sc2::Color> color(m, "Color");
color.def(py::init<>());
color.def(py::init<int, int, int>(), "r"_a, "g"_a, "b"_a);
color.def_readwrite("r", &sc2::Color::r, "Red");
color.def_readwrite("g", &sc2::Color::g, "Green");
color.def_readwrite("b", &sc2::Color::b, "Blue");
color.attr("WHITE") = sc2::Colors::White;
color.attr("RED") = sc2::Colors::Red;
color.attr("GREEN") = sc2::Colors::Green;
color.attr("YELLOW") = sc2::Colors::Yellow;
color.attr("BLUE") = sc2::Colors::Blue;
color.attr("TEAL") = sc2::Colors::Teal;
color.attr("PURPLE") = sc2::Colors::Purple;
color.attr("BLACK") = sc2::Colors::Black;
color.attr("GRAY") = sc2::Colors::Gray;
m.def("create_participants", &sc2::CreateParticipant, "Create participant from bot", "race"_a, "bot"_a); m.def("create_participants", &sc2::CreateParticipant, "Create participant from bot", "race"_a, "bot"_a);
m.def("create_computer", &sc2::CreateComputer, "Create participant from built-in Starcraft computer", "race"_a, "difficulty"_a); m.def("create_computer", &sc2::CreateComputer, "Create participant from built-in Starcraft computer", "race"_a, "difficulty"_a);
......
...@@ -56,5 +56,6 @@ void define_util(pybind11::module &m); ...@@ -56,5 +56,6 @@ void define_util(pybind11::module &m);
void define_point(pybind11::module &m); void define_point(pybind11::module &m);
void define_base_location(pybind11::module & m); void define_base_location(pybind11::module & m);
void define_tech_tree(pybind11::module & m); void define_tech_tree(pybind11::module & m);
void define_color(pybind11::module & m);
void define_map_tools(pybind11::module & m); void define_map_tools(pybind11::module & m);
void define_building_placer(pybind11::module & m); void define_building_placer(pybind11::module & m);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment