[Application] Template code added to start Lua API later.

This commit is contained in:
Quentin Bazin 2018-12-19 22:36:20 +01:00
parent 4ad7257c44
commit 3e6751e6e6
4 changed files with 22195 additions and 10 deletions

View File

@ -12,8 +12,8 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Get source files # Get source files
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
file(GLOB_RECURSE SOURCE_FILES source/*.cpp) file(GLOB_RECURSE SOURCE_FILES source/*.cpp external/*.cpp)
file(GLOB_RECURSE HEADER_FILES include/*.hpp) file(GLOB_RECURSE HEADER_FILES include/*.hpp external/*.hpp)
foreach(HEADER_FILE ${HEADER_FILES}) foreach(HEADER_FILE ${HEADER_FILES})
get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY) get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY)
@ -35,15 +35,15 @@ target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_17)
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# Packages # Packages
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# - jsoncpp # - Lua
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
find_package(JsonCpp REQUIRED) find_package(Lua REQUIRED)
if(NOT JSONCPP_FOUND) if(NOT LUA_FOUND)
message(FATAL_ERROR "jsoncpp is needed to build the project. Please install it correctly.") message(FATAL_ERROR "Lua is needed to build the project. Please install it correctly.")
endif() endif()
include_directories(${JSONCPP_INCLUDE_DIRS}) include_directories(${LUA_INCLUDE_DIRS})
link_directories(${JSONCPP_LIBRARY_DIRS}) link_directories(${LUA_LIBRARY_DIRS})
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# - tinyxml2 # - tinyxml2
@ -104,7 +104,7 @@ include_directories(${SDL2_INCLUDE_DIRS}
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
target_link_libraries(${CMAKE_PROJECT_NAME} target_link_libraries(${CMAKE_PROJECT_NAME}
${TINYXML2_LIBRARIES} ${TINYXML2_LIBRARIES}
${JSONCPP_LIBRARIES} ${LUA_LIBRARIES}
${OPENGL_LIBRARIES} ${OPENGL_LIBRARIES}
${SDL2_LIBRARIES} ${SDL2_LIBRARIES}
${SDL2IMAGE_LIBRARIES} ${SDL2IMAGE_LIBRARIES}

22180
external/sol.hpp vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,6 +14,8 @@
#ifndef APPLICATION_HPP_ #ifndef APPLICATION_HPP_
#define APPLICATION_HPP_ #define APPLICATION_HPP_
#include <sol.hpp>
#include "CoreApplication.hpp" #include "CoreApplication.hpp"
#include "Registry.hpp" #include "Registry.hpp"
@ -27,6 +29,7 @@ class Application : public CoreApplication {
private: private:
Registry m_registry; Registry m_registry;
sol::state m_lua;
}; };
#endif // APPLICATION_HPP_ #endif // APPLICATION_HPP_

View File

@ -37,6 +37,9 @@ void Application::init() {
m_registry.registerItems(); m_registry.registerItems();
m_registry.registerRecipes(); m_registry.registerRecipes();
m_lua.open_libraries();
m_lua.script("print('lol')");
m_stateStack.push<GameState>(); m_stateStack.push<GameState>();
} }
@ -71,4 +74,3 @@ void Application::initOpenGL() {
glClearColor(0.196078, 0.6, 0.8, 1.0); // Skyblue glClearColor(0.196078, 0.6, 0.8, 1.0); // Skyblue
} }