diff options
author | Stephen Enders <84310577289916ceefd4132143fb36b63a5f0c71> | 2022-06-22 01:28:23 -0400 |
---|---|---|
committer | Steph Enders <smenders@gmail.com> | 2022-06-21 22:28:30 -0400 |
commit | a878cdc42bf41355758dabd353d521d4b12e73fc (patch) | |
tree | 312acaf0cd8724b42e692fc26945f2992467ed19 /src/main.cpp | |
parent | 09615be926efb7302bc348aa66feccb694b23ba8 (diff) |
Add windows support
Create res.h for handling resource loading
Update CMakeLists.txt to ensure compilation is passed properly
Fix unsupported functions (<limits>) on Windows
Use to_str(path) to get path as c_str() returns wchar_t* on windows
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main.cpp b/src/main.cpp index 99f8603..0034677 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,6 +32,9 @@ #ifdef __linux__ #include "linux/res.h" #endif +#ifdef _WIN32 +#include "windows/res.h" +#endif #include "lua.hpp" #include <SFML/Graphics.hpp> #include <cmath> @@ -55,14 +58,13 @@ int main(int argc, char **argv) { std::string lvl_pfx = argv[1]; - std::filesystem::path mapFile{lvl_pfx + "/dng.map"}; - std::filesystem::path luaFile{lvl_pfx + "/proc.lua"}; + std::filesystem::path mapFile = lvl_pfx / std::filesystem::path{"dng.map"}; + std::filesystem::path luaFile = lvl_pfx / std::filesystem::path{"proc.lua"}; lvl = std::make_shared<Level>(); scene = Scene::INTRO; - lvl->loadLevelFromFile(mapFile.c_str()); - + lvl->loadLevelFromFile(to_str(mapFile)); lua_State *L_lvl = luaL_newstate(); luaL_openlibs(L_lvl); init_c_api(L_lvl); @@ -72,7 +74,7 @@ int main(int argc, char **argv) { init_c_api(L_default); if (std::filesystem::exists(res.defaultsFile) && - luaL_dofile(L_default, res.defaultsFile.c_str()) != LUA_OK) { + luaL_dofile(L_default, to_str(res.defaultsFile)) != LUA_OK) { std::cout << "Failed to load default proc" << std::endl; luaL_error(L_default, "Error: %s", lua_tostring(L_default, -1)); return EXIT_FAILURE; @@ -82,7 +84,7 @@ int main(int argc, char **argv) { LState *l_state = init_default(L_default); if (std::filesystem::exists(luaFile) && - luaL_dofile(L_lvl, luaFile.c_str()) == LUA_OK) { + luaL_dofile(L_lvl, to_str(luaFile)) == LUA_OK) { override_file_fns(L_lvl, l_state); } else if (std::filesystem::exists(luaFile)) { std::cout << "[C] No Good" << std::endl; @@ -124,7 +126,7 @@ int main(int argc, char **argv) { window.setView(view); sf::Clock deltaClock; sf::Font font; - font.loadFromFile(res.fontFile); + font.loadFromFile(to_str(res.fontFile)); MessageBox intro; MessageBox win; |