Skip to content

Commit 4e405c6

Browse files
committed
Moved window size into graphics.conf
1 parent c9cfbb2 commit 4e405c6

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

resources/graphics.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
font.path=resources/ComicNeue-Bold.ttf
33
font.size=50
44

5+
# General window settings
6+
screen.width=900
7+
screen.height=800
8+
59
# Trading view screen coordinates
610
screen.tradingView.bottomLeft=(0.1,0.1)
711
screen.tradingView.topRight=(0.9,0.9)

src/GameView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ bool GameView::acceptInput(SDL_Event& event) {
154154
if(event.type == SDL_QUIT) {
155155
return false;
156156
} else if(event.type == SDL_MOUSEBUTTONUP) {
157-
ScreenCoordinate screen = {(float) event.button.x / 900.f, 1.f - (float) event.button.y / 800.f};
157+
ScreenCoordinate screen = {(float) event.button.x / getGraphicsConfig()["screen.width"], 1.f - (float) event.button.y / getGraphicsConfig()["screen.height"]};
158158
for(auto& it : viewElements) {
159159
if(it.second->handleClick(screen)) {
160160
//break;

src/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <vector>
1414
#include <memory>
1515

16+
#include "Config.h"
1617
#include "GameBoard.h"
1718
#include "Player.h"
1819
#include "GameView.h"
@@ -50,7 +51,6 @@ void updateViewport(int width, int height) {
5051
* Main. Initializes SDL and the model, view, and controller. Also has the main game loop.
5152
*/
5253
int main(int argc, char *argv[]) {
53-
const int windowWidth = 900, windowHeight = 800;
5454

5555
if(TTF_Init()==-1) {
5656
std::cout << "Error in TTF_Init: " << TTF_GetError() << std::endl;
@@ -61,7 +61,7 @@ int main(int argc, char *argv[]) {
6161
SDL_Window* displayWindow;
6262
SDL_Renderer* displayRenderer;
6363
SDL_RendererInfo displayRendererInfo;
64-
SDL_CreateWindowAndRenderer(windowWidth, windowHeight, SDL_WINDOW_OPENGL, &displayWindow, &displayRenderer);
64+
SDL_CreateWindowAndRenderer(getGraphicsConfig()["screen.width"], getGraphicsConfig()["screen.height"], SDL_WINDOW_OPENGL, &displayWindow, &displayRenderer);
6565
SDL_GetRendererInfo(displayRenderer, &displayRendererInfo);
6666
/*TODO: Check that we have OpenGL */
6767
if ((displayRendererInfo.flags & SDL_RENDERER_ACCELERATED) == 0 ||
@@ -74,7 +74,7 @@ int main(int argc, char *argv[]) {
7474

7575
initOpenGL();
7676

77-
updateViewport(windowWidth, windowHeight);
77+
updateViewport(getGraphicsConfig()["screen.width"], getGraphicsConfig()["screen.height"]);
7878

7979
GameBoard model({"Player1", "Player2", "Player3", "Player4"});
8080
GameView view(model);

0 commit comments

Comments
 (0)