diff --git a/blooblib/blooblib.vcxproj b/blooblib/blooblib.vcxproj index 2d5b8a1..e5c36ac 100644 --- a/blooblib/blooblib.vcxproj +++ b/blooblib/blooblib.vcxproj @@ -73,13 +73,13 @@ StaticLibrary true - v143 + ClangCL Unicode StaticLibrary false - v143 + ClangCL true Unicode diff --git a/blooblib/include/game.h b/blooblib/include/game.h index afde268..86afa98 100644 --- a/blooblib/include/game.h +++ b/blooblib/include/game.h @@ -5,7 +5,7 @@ #include "resource_manager.h" struct game { - game(); + game(int argc, char* argv[]); void run(); virtual void init(settings& settings); @@ -22,6 +22,8 @@ private: image const* _cursor; resource_manager _rm; int _fps; + int _argc; + char** _argv; }; template diff --git a/blooblib/include/resource_manager.h b/blooblib/include/resource_manager.h index 54eb302..d9c34bb 100644 --- a/blooblib/include/resource_manager.h +++ b/blooblib/include/resource_manager.h @@ -17,7 +17,7 @@ */ struct resource_manager { - resource_manager(); + resource_manager(int argc, char** argv); void mount(std::string const& path, std::string const& mounting_point); template diff --git a/blooblib/src/font.cpp b/blooblib/src/font.cpp index e5ae2bf..9762de8 100644 --- a/blooblib/src/font.cpp +++ b/blooblib/src/font.cpp @@ -28,8 +28,8 @@ font::font(resource_manager& rm, ini_category const* ini, std::string const& pat _glyphs.at(ch).draw(image, vec2i::zero, r); } } else { - int width = ini->get("width"); - int height = ini->get("height"); + int width = ini->get("tile_width"); + int height = ini->get("tile_height"); auto ts = rm.get(path); _lineheight = ts->_tile_size.y; for(int i = 0; i < 256; ++i) { diff --git a/blooblib/src/game.cpp b/blooblib/src/game.cpp index 40a0a93..6f40811 100644 --- a/blooblib/src/game.cpp +++ b/blooblib/src/game.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include "image.h" #include "settings.h" @@ -18,12 +17,14 @@ LRESULT WINAPI wnd_proc(HWND window, UINT msg, WPARAM w, LPARAM l) { return ::DefWindowProc(window, msg, w, l); } -game::game() : _cursor(0) { +game::game(int argc, char** argv) : _cursor(0), _argc(argc), _argv(argv), _rm(argc, argv) { + std::cout << "a\n"; } void play_logo(HWND window, image const* logo, image const* logo_slime); void game::run() { + std::cout << "a\n"; settings settings; init(settings); auto title = std::wstring(settings.title.begin(), settings.title.end()); diff --git a/blooblib/src/resource_manager.cpp b/blooblib/src/resource_manager.cpp index 9de2207..111833d 100644 --- a/blooblib/src/resource_manager.cpp +++ b/blooblib/src/resource_manager.cpp @@ -6,14 +6,17 @@ #define BP_INSER_RESOURCES #include "system_assets.h" -resource_manager::resource_manager() { - PHYSFS_init(0); +resource_manager::resource_manager(int argc, char** argv) { + if(!PHYSFS_init(argv[0])) + throw std::runtime_error(std::format("physfs error: {}", PHYSFS_getLastError())); mount("assets", "/"); - PHYSFS_mountMemory(BP_system_assets, sizeof(BP_system_assets), 0, "system-assets", "/", 0); + if(!PHYSFS_mountMemory(BP_system_assets, sizeof(BP_system_assets), 0, "system-assets", "/", 0)) + throw std::runtime_error(std::format("physfs error: {}", PHYSFS_getLastError())); } void resource_manager::mount(std::string const& path, std::string const& mounting_point) { - PHYSFS_mount(path.c_str(), mounting_point.c_str(), 0); + if(!PHYSFS_mount(path.c_str(), mounting_point.c_str(), 0)) + throw std::runtime_error(std::format("physfs error: {}", PHYSFS_getLastError())); } std::vector resource_manager::read(std::filesystem::path const& path) { diff --git a/test/test.cpp b/test/test.cpp index 53aeab9..12c6c8c 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -2,6 +2,7 @@ #include "bloob.h" struct my_game : game { + my_game(int argc, char** argv) : game(argc, argv) {} void init(settings& settings); void update(); void render(image& target); @@ -79,7 +80,7 @@ void my_game::render(image& target) { } int main(int argc, char* argv[]) { - my_game game; + my_game game(argc, argv); game.run(); return 0; } diff --git a/test/test.vcxproj b/test/test.vcxproj index d0eed52..9fbb0ff 100644 --- a/test/test.vcxproj +++ b/test/test.vcxproj @@ -42,13 +42,13 @@ Application true - v143 + ClangCL Unicode Application false - v143 + ClangCL true Unicode