argv[0] to resource manager, building with clang
This commit is contained in:
parent
82187b9005
commit
147bd4a206
|
@ -73,13 +73,13 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -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<typename T>
|
||||
|
|
|
@ -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 <typename T>
|
||||
|
|
|
@ -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<int>("width");
|
||||
int height = ini->get<int>("height");
|
||||
int width = ini->get<int>("tile_width");
|
||||
int height = ini->get<int>("tile_height");
|
||||
auto ts = rm.get<tileset>(path);
|
||||
_lineheight = ts->_tile_size.y;
|
||||
for(int i = 0; i < 256; ++i) {
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include <chrono>
|
||||
#include <format>
|
||||
#include <iostream>
|
||||
#include <SDL3/SDL.h>
|
||||
#include <Windows.h>
|
||||
#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());
|
||||
|
|
|
@ -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<uint8_t> resource_manager::read(std::filesystem::path const& path) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -42,13 +42,13 @@
|
|||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<PlatformToolset>ClangCL</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
|
|
Loading…
Reference in New Issue