whoohohoh

This commit is contained in:
/nick haya 2022-02-22 13:32:23 +08:00
parent b42a5e324d
commit 8749aac2fd
7 changed files with 45 additions and 53 deletions

View file

@ -5,42 +5,48 @@ cmake_minimum_required(VERSION 3.10)
project(Skateboard)
# include directories
set(SDL2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SDL2/")
set(OUT_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/")
set(OUT2_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/MIDI/")
set(OUT3_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/toml/")
set(OUT4_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/sdfml/")
set(OUT5_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SDL_gpu/")
set(OUT6_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/lua/lua/")
set(OUT7_INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/lua/")
set(INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/SDL2/"
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/"
"${CMAKE_CURRENT_LIST_DIR}/src/SoLoud/MIDI/"
"${CMAKE_CURRENT_LIST_DIR}/src/toml/"
"${CMAKE_CURRENT_LIST_DIR}/src/sdfml/"
"${CMAKE_CURRENT_LIST_DIR}/src/SDL_gpu/"
"${CMAKE_CURRENT_LIST_DIR}/src/lua/lua/"
"${CMAKE_CURRENT_LIST_DIR}/src/lua/"
)
option(PREFER_MODPLUG "Use libmodplug api instead of libopenmpt for module playback" ON)
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
set(MAIN_LIBRARIES_E "${CMAKE_CURRENT_LIST_DIR}/lib/x64")
else ()
set(MAIN_LIBRARIES_E "${CMAKE_CURRENT_LIST_DIR}/lib/x86")
endif ()
# Lib paths
set(suffix "${CMAKE_CURRENT_LIST_DIR}/lib")
# Support both 32 and 64 bit builds
# Someone make a pull request to support MingW
# Way to lazy to do that right now
set(MAIN_LIBRARIES "${MAIN_LIBRARIES_E}/luajit.lib;${MAIN_LIBRARIES_E}/lua51.lib;${MAIN_LIBRARIES_E}/SDL2_gpu.lib;${MAIN_LIBRARIES_E}/libmodplug.lib;${MAIN_LIBRARIES_E}/soloud_static.lib;${MAIN_LIBRARIES_E}/SDL2.lib;${MAIN_LIBRARIES_E}/SDL2_ttf.lib")
if (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
set(LIB_PATH "${suffix}/x64")
else ()
set(LIB_PATH "${suffix}/x86")
endif ()
# Lib files
# MingW supports .lib files now I believe??
set(MAIN_LIBRARIES "luajit.lib"
"lua51.lib"
"SDL2_gpu.lib"
"libmodplug.lib"
"soloud_static.lib"
"SDL2.lib"
"SDL2_ttf.lib")
# strip it all
string(STRIP "${MAIN_LIBRARIES}" MAIN_LIBRARIES)
# Include the damn directories
include_directories(${SDL2_INCLUDE_DIRS})
include_directories(${OUT_INCLUDE_DIRS})
include_directories(${OUT2_INCLUDE_DIRS})
include_directories(${OUT3_INCLUDE_DIRS})
include_directories(${OUT4_INCLUDE_DIRS})
include_directories(${OUT5_INCLUDE_DIRS})
include_directories(${OUT6_INCLUDE_DIRS})
include_directories(${OUT7_INCLUDE_DIRS})
include_directories(${INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
# library dirs
link_directories(${LIB_PATH})
# add EVERY FUCKING source file to SOURCES
FILE(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/*.hpp"
@ -61,6 +67,8 @@ FILE(GLOB SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/src/lua/lua/*.h"
)
FILE(GLOB DLLS "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp")
# set c++ std to 17
set(CMAKE_CXX_STANDARD 17)
@ -74,8 +82,12 @@ if ( MSVC )
target_compile_options(Skateboard PRIVATE /W1)
endif()
# LINK EVERYTHING
target_link_libraries(Skateboard ${MAIN_LIBRARIES})
# MingW : for a lib file to not require lib before the name
if (MINGW)
target_link_libraries(Skateboard ":${MAIN_LIBRARIES}")
else()
target_link_libraries(Skateboard ${MAIN_LIBRARIES})
endif()
# set build dir
set(BUILD_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
@ -90,7 +102,7 @@ set_target_properties(Skateboard PROPERTIES
)
# copy dll files
file(COPY "${MAIN_LIBRARIES_E}/" DESTINATION ${BUILD_DIRECTORY})
file(COPY "${LIB_PATH}/" DESTINATION ${BUILD_DIRECTORY})
# remove lib files
file(REMOVE_RECURSE "${BUILD_DIRECTORY}/*.lib")

View file

@ -67,6 +67,7 @@ ExampleState m;
int main(int argc, char* argv[])
{
if (sdfml::init() > 0) {
sdfml::llog("game died", "", NORMAL, __FILENAME__, __LINE__);
return EXIT_FAILURE;
}

View file

@ -405,8 +405,6 @@ namespace sdfml {
static GPU_Camera camera;
static LuaHandler lua;
inline int init(float width = DEFAULT_WINDOW_WIDTH, float height = DEFAULT_WINDOW_HEIGHT, string window_name = "Unknown",
int win_flags = SDL_WINDOW_OPENGL|SDL_WINDOW_ALLOW_HIGHDPI|SDL_WINDOW_SHOWN) {
std::ofstream logFile;
@ -439,7 +437,7 @@ namespace sdfml {
mContext.direct_win = wmInfo.info.win.window;
sound.init();
sound.initSF(soundfont);
llog("SoLoud", " is now initialized.", NORMAL, __FILENAME__, __LINE__);
camera = GPU_GetDefaultCamera();

View file

@ -27239,7 +27239,7 @@ namespace sol {
using iterator = typename global_table::iterator;
using const_iterator = typename global_table::const_iterator;
state_view(lua_State* Ls = NULL) : L(Ls), reg(Ls, LUA_REGISTRYINDEX), global(Ls, global_tag) {
state_view(lua_State* Ls) : L(Ls), reg(Ls, LUA_REGISTRYINDEX), global(Ls, global_tag) {
}
state_view(this_state Ls) : state_view(Ls.L) {

View file

@ -6,7 +6,5 @@ std::pair<SoLoud::WavStream, SoLoud::Modplug> sdfml::musicBank;
#else
std::pair<SoLoud::WavStream, SoLoud::Openmpt> sdfml::musicBank;
#endif
SoLoud::Midi sdfml::midiBank;
SoLoud::SoundFont sdfml::midiSF;
SoLoud::Soloud sdfml::audio;
sdfml::AudioHandler sdfml::sound;

View file

@ -20,18 +20,11 @@ namespace sdfml {
#else
extern std::pair<SoLoud::WavStream, SoLoud::Openmpt> musicBank;
#endif
extern SoLoud::Midi midiBank;
extern SoLoud::SoundFont midiSF;
extern SoLoud::Soloud audio;
class MusicHandler {
public:
void playMidi(std::string path) {
}
void playMusic(std::string path) {
musicBank.first.stop();
@ -58,10 +51,6 @@ namespace sdfml {
audio.init(audio.CLIP_ROUNDOFF, audio.MINIAUDIO);
}
void initSF(std::string path) {
midiSF.load(path.c_str());
}
void deinit() {
audio.stopAll();
audio.deinit();

View file

@ -12,22 +12,14 @@ namespace sdfml {
class LuaHandler {
protected:
sol::state _lua_state;
sol::state_view _lua_view;
sol::state_view _lua_view = NULL;
sol::load_result _cur_result;
bool _prefer_view = false;
public:
LuaHandler() {
sol::state_view temp(NULL);
_lua_view = temp;
}
int open_state(std::string path, bool immediate = false);
int create_from_lua_state(lua_State* L, std::string path, bool immediate = false);
int open_from_lua_state(lua_State* L, std::string path, bool immediate = false) {
return create_from_lua_state(L, path, immediate);
}
int run_state();
template <typename TName = int>
@ -39,6 +31,8 @@ namespace sdfml {
template <typename... Args>
void add_libraries(Args&&... libraries);
};
//static LuaHandler lua;
}
#endif