From 691ea06eb0afde281f35c0e92f60c800836396c4 Mon Sep 17 00:00:00 2001 From: freezarite Date: Mon, 16 Dec 2024 06:02:58 +0100 Subject: [PATCH] Added and implemented some more config options in the GameInternal.cpp. Also removed GameInternal::init() parameters as they are no longer needed --- config.json | 6 +++++- include/GameInternal.h | 2 +- src/GameInternal.cpp | 6 +++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config.json b/config.json index 2aff41b..0e0eb80 100644 --- a/config.json +++ b/config.json @@ -1,3 +1,7 @@ { - "fullscreen": false + "fullscreen": false, + "title": "VGG (Very Good Game)", + "height": 100, + "width": 100, + "icon": "./engine/internalAssets/iconImage.bmp" } \ No newline at end of file diff --git a/include/GameInternal.h b/include/GameInternal.h index 7cb3b1f..98c8fd1 100644 --- a/include/GameInternal.h +++ b/include/GameInternal.h @@ -27,7 +27,7 @@ public: GameInternal(); ~GameInternal(); - SDL_AppResult init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen); + SDL_AppResult init(); void handleEvents(); void update(Uint64 frameTime); diff --git a/src/GameInternal.cpp b/src/GameInternal.cpp index c1df0be..7d5f5fc 100644 --- a/src/GameInternal.cpp +++ b/src/GameInternal.cpp @@ -29,7 +29,7 @@ GameInternal::GameInternal() : 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); 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; } - window = SDL_CreateWindow(title, width, height, flags); + window = SDL_CreateWindow(config.at("title").get().c_str(), config.at("width"), config.at("height"), flags); if (!window) { 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 SDL_Surface* icon; - if((icon = SDL_LoadBMP("assets/iconImage.bmp"))) + if((icon = SDL_LoadBMP(config.at("icon").get().c_str()))) { SDL_SetWindowIcon(window, icon); }