0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 10:13:42 +00:00

Added and implemented some more config options in the GameInternal.cpp. Also removed GameInternal::init() parameters as they are no longer needed

This commit is contained in:
freezarite 2024-12-16 06:02:58 +01:00
parent acdbf29896
commit 691ea06eb0
3 changed files with 9 additions and 5 deletions

View File

@ -1,3 +1,7 @@
{ {
"fullscreen": false "fullscreen": false,
"title": "VGG (Very Good Game)",
"height": 100,
"width": 100,
"icon": "./engine/internalAssets/iconImage.bmp"
} }

View File

@ -27,7 +27,7 @@ public:
GameInternal(); GameInternal();
~GameInternal(); ~GameInternal();
SDL_AppResult init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen); SDL_AppResult init();
void handleEvents(); void handleEvents();
void update(Uint64 frameTime); void update(Uint64 frameTime);

View File

@ -29,7 +29,7 @@ GameInternal::GameInternal() :
GameInternal::~GameInternal() = default; GameInternal::~GameInternal() = default;
SDL_AppResult GameInternal::init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen) SDL_AppResult GameInternal::init()
{ {
this->gameInstance = GameFactory::instance().create(this); this->gameInstance = GameFactory::instance().create(this);
ConfigLoader().setCustomConfig(this->gameInstance->getConfigFilePath()); ConfigLoader().setCustomConfig(this->gameInstance->getConfigFilePath());
@ -60,7 +60,7 @@ SDL_AppResult GameInternal::init(const char* title, int xpos, int ypos, int widt
return SDL_APP_FAILURE; return SDL_APP_FAILURE;
} }
window = SDL_CreateWindow(title, width, height, flags); window = SDL_CreateWindow(config.at("title").get<std::string>().c_str(), config.at("width"), config.at("height"), flags);
if (!window) if (!window)
{ {
std::cout << "ERROR: Window couldnt be created! " << SDL_GetError() << std::endl; std::cout << "ERROR: Window couldnt be created! " << SDL_GetError() << std::endl;
@ -70,7 +70,7 @@ SDL_AppResult GameInternal::init(const char* title, int xpos, int ypos, int widt
// bad // bad
SDL_Surface* icon; SDL_Surface* icon;
if((icon = SDL_LoadBMP("assets/iconImage.bmp"))) if((icon = SDL_LoadBMP(config.at("icon").get<std::string>().c_str())))
{ {
SDL_SetWindowIcon(window, icon); SDL_SetWindowIcon(window, icon);
} }