|
| 1 | +#include "ChaiScript/include/chaiscript/chaiscript.hpp" |
| 2 | + |
| 3 | +#include "game.hpp" |
| 4 | +#include "map.hpp" |
| 5 | +#include "game_event.hpp" |
| 6 | + |
| 7 | +#define ADD_FUN(Class, Name) module->add(chaiscript::fun(&Class::Name), "Name") |
| 8 | + |
| 9 | +std::shared_ptr<chaiscript::Module> create_chaiscript_bindings() |
| 10 | +{ |
| 11 | + auto module = std::shared_ptr<chaiscript::Module>(new chaiscript::Module()); |
| 12 | + |
| 13 | + ADD_FUN(Game, get_texture); |
| 14 | + ADD_FUN(Game, get_font); |
| 15 | + ADD_FUN(Game, teleport_to); |
| 16 | + ADD_FUN(Game, set_avatar); |
| 17 | + ADD_FUN(Game, add_map); |
| 18 | + ADD_FUN(Game, add_start_action); |
| 19 | + ADD_FUN(Game, add_queued_action); |
| 20 | + ADD_FUN(Game, show_message_box); |
| 21 | + ADD_FUN(Game, show_object_interaction_menu); |
| 22 | + ADD_FUN(Game, show_conversation); |
| 23 | + ADD_FUN(Game, has_pending_events); |
| 24 | + ADD_FUN(Game, get_current_event); |
| 25 | + ADD_FUN(Game, update); |
| 26 | + ADD_FUN(Game, draw); |
| 27 | + ADD_FUN(Game, get_avatar_position); |
| 28 | + ADD_FUN(Game, enter_map); |
| 29 | + ADD_FUN(Game, has_current_map); |
| 30 | + ADD_FUN(Game, get_current_map); |
| 31 | + ADD_FUN(Game, start); |
| 32 | + ADD_FUN(Game, set_flag); |
| 33 | + ADD_FUN(Game, get_flag); |
| 34 | + ADD_FUN(Game, set_rotate); |
| 35 | + ADD_FUN(Game, set_zoom); |
| 36 | + ADD_FUN(Game, rotate); |
| 37 | + ADD_FUN(Game, zoom); |
| 38 | + |
| 39 | + module->add(chaiscript::fun(&Game::get_input_direction_vector), "get_input_direction_vector"); |
| 40 | + |
| 41 | + module->add(chaiscript::constructor<Answer (std::string, std::string)>(), "Answer"); |
| 42 | + |
| 43 | + module->add(chaiscript::constructor< |
| 44 | + Question (std::string, std::vector<Answer>, |
| 45 | + std::function<bool (const float, const float, Game &, Object &)>, |
| 46 | + std::function<void (const float, const float, Game &, Object &)>)>(), "Question"); |
| 47 | + |
| 48 | + module->add(chaiscript::constructor<Conversation(std::vector<Question>)>(), "Conversation"); |
| 49 | + |
| 50 | + module->add(chaiscript::constructor<Game_Action(std::string, std::function<void (const float, const float, Game &)>)>(), "Game_Action"); |
| 51 | + ADD_FUN(Game_Action, description); |
| 52 | + ADD_FUN(Game_Action, action); |
| 53 | + |
| 54 | + module->add(chaiscript::constructor<Object_Action(std::string, std::function<void (const float, const float, Game &, Object &)>)>(), "Object_Action"); |
| 55 | + ADD_FUN(Object_Action, description); |
| 56 | + ADD_FUN(Object_Action, action); |
| 57 | + |
| 58 | + |
| 59 | + module->add(chaiscript::constructor<Object(std::string, const sf::Texture &, const int, const int, const float, |
| 60 | + std::function<void (const float, const float, Game &, Object &, sf::Sprite &)> , |
| 61 | + std::function<std::vector<Object_Action> (const float, const float, Game &, Object &)> )>(), "Object"); |
| 62 | + |
| 63 | + ADD_FUN(Object, update); |
| 64 | + ADD_FUN(Object, get_actions); |
| 65 | + ADD_FUN(Object, do_collision); |
| 66 | + |
| 67 | + module->add(chaiscript::constructor<Tile_Properties(bool)>(), "Tile_Properties"); |
| 68 | + module->add(chaiscript::constructor<Tile_Properties(bool, std::function<void (float, float)>)>(), "Tile_Properties"); |
| 69 | + ADD_FUN(Tile_Properties, do_movement_action); |
| 70 | + ADD_FUN(Tile_Properties, passable); |
| 71 | + ADD_FUN(Tile_Properties, movement_action); |
| 72 | + |
| 73 | + module->add(chaiscript::constructor<Tile_Defaults(const int, Tile_Properties)>(), "Tile_Defaults"); |
| 74 | + |
| 75 | + module->add(chaiscript::constructor<Tile_Map(Game &, const std::string &, std::vector<Tile_Defaults>)>(), "Tile_Map"); |
| 76 | + |
| 77 | + ADD_FUN(Tile_Map, add_enter_action); |
| 78 | + ADD_FUN(Tile_Map, enter); |
| 79 | + ADD_FUN(Tile_Map, dimensions_in_pixels); |
| 80 | + ADD_FUN(Tile_Map, add_object); |
| 81 | + ADD_FUN(Tile_Map, get_bounding_box); |
| 82 | + ADD_FUN(Tile_Map, test_move); |
| 83 | + ADD_FUN(Tile_Map, get_collisions); |
| 84 | + ADD_FUN(Tile_Map, adjust_move); |
| 85 | + ADD_FUN(Tile_Map, do_move); |
| 86 | + ADD_FUN(Tile_Map, update); |
| 87 | + |
| 88 | + |
| 89 | + return module; |
| 90 | +} |
| 91 | + |
0 commit comments