aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/crepe/facade/SDLContext.cpp26
-rw-r--r--src/test/CMakeLists.txt2
-rw-r--r--src/test/InputTest.cpp3
-rw-r--r--src/test/Profiling.cpp3
-rw-r--r--src/test/RenderSystemTest.cpp9
5 files changed, 19 insertions, 24 deletions
diff --git a/src/crepe/facade/SDLContext.cpp b/src/crepe/facade/SDLContext.cpp
index 8353cef..c46e0d0 100644
--- a/src/crepe/facade/SDLContext.cpp
+++ b/src/crepe/facade/SDLContext.cpp
@@ -284,8 +284,8 @@ void SDLContext::update_camera_view(const Camera & cam, const vec2 & new_pos) {
// resize window
int w, h;
SDL_GetWindowSize(this->game_window.get(), &w, &h);
- if (w != config.window_settings.default_size.x || h != config.window_settings.default_size.y) {
- SDL_SetWindowSize(this->game_window.get(), config.window_settings.default_size.x, config.window_settings.default_size.y);
+ if (w != config.window.size.x || h != config.window.size.y) {
+ SDL_SetWindowSize(this->game_window.get(), config.window.size.x, config.window.size.y);
}
vec2 & zoomed_viewport = this->cam_aux_data.zoomed_viewport;
@@ -294,28 +294,28 @@ void SDLContext::update_camera_view(const Camera & cam, const vec2 & new_pos) {
this->cam_aux_data.cam_pos = new_pos;
zoomed_viewport = cam.viewport_size * cam_data.zoom;
- float screen_aspect = static_cast<float>(config.window_settings.default_size.x) / config.window_settings.default_size.y;
+ float screen_aspect = static_cast<float>(config.window.size.x) / config.window.size.y;
float viewport_aspect = zoomed_viewport.x / zoomed_viewport.y;
// calculate black bars
if (screen_aspect > viewport_aspect) {
// pillarboxing
- float scale = config.window_settings.default_size.y / zoomed_viewport.y;
+ float scale = config.window.size.y / zoomed_viewport.y;
float adj_width = zoomed_viewport.x * scale;
- float bar_width = (config.window_settings.default_size.x - adj_width) / 2;
- this->black_bars[0] = {0, 0, bar_width, (float) config.window_settings.default_size.y};
- this->black_bars[1] = {(config.window_settings.default_size.x - bar_width), 0, bar_width, (float) config.window_settings.default_size.y};
+ float bar_width = (config.window.size.x - adj_width) / 2;
+ this->black_bars[0] = {0, 0, bar_width, (float) config.window.size.y};
+ this->black_bars[1] = {(config.window.size.x - bar_width), 0, bar_width, (float) config.window.size.y};
bar_size = {bar_width, 0};
render_scale.x = render_scale.y = scale;
} else {
// letterboxing
- float scale = config.window_settings.default_size.x / (cam.viewport_size.x * cam_data.zoom);
+ float scale = config.window.size.x / (cam.viewport_size.x * cam_data.zoom);
float adj_height = cam.viewport_size.y * scale;
- float bar_height = (config.window_settings.default_size.y - adj_height) / 2;
- this->black_bars[0] = {0, 0, (float) config.window_settings.default_size.x, bar_height};
+ float bar_height = (config.window.size.y - adj_height) / 2;
+ this->black_bars[0] = {0, 0, (float) config.window.size.x, bar_height};
this->black_bars[1]
- = {0, (config.window_settings.default_size.y - bar_height), (float) config.window_settings.default_size.x, bar_height};
+ = {0, (config.window.size.y - bar_height), (float) config.window.size.x, bar_height};
bar_size = {0, bar_height};
render_scale.x = render_scale.y = scale;
@@ -327,8 +327,8 @@ void SDLContext::update_camera_view(const Camera & cam, const vec2 & new_pos) {
SDL_Rect bg = {
.x = 0,
.y = 0,
- .w = config.window_settings.default_size.x,
- .h = config.window_settings.default_size.y,
+ .w = config.window.size.x,
+ .h = config.window.size.y,
};
// fill bg color
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index ea92d96..d1c5a38 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -17,7 +17,7 @@ target_sources(test_main PUBLIC
Vector2Test.cpp
# LoopManagerTest.cpp
LoopTimerTest.cpp
- InputTest.cpp
+ # InputTest.cpp
ScriptEventTest.cpp
ScriptSceneTest.cpp
Profiling.cpp
diff --git a/src/test/InputTest.cpp b/src/test/InputTest.cpp
index 41142ba..ee362be 100644
--- a/src/test/InputTest.cpp
+++ b/src/test/InputTest.cpp
@@ -36,8 +36,7 @@ protected:
void SetUp() override {
GameObject obj = mgr.new_object("camera", "camera", vec2{0, 0}, 0, 1);
auto & camera
- = obj.add_component<Camera>(ivec2{500, 500}, vec2{500, 500},
- Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
+ = obj.add_component<Camera>(vec2{500, 500}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
render.frame_update();
//mediator.event_manager = event_manager;
//mediator.component_manager = mgr;
diff --git a/src/test/Profiling.cpp b/src/test/Profiling.cpp
index 7dbf110..45f6d4c 100644
--- a/src/test/Profiling.cpp
+++ b/src/test/Profiling.cpp
@@ -75,8 +75,7 @@ public:
void SetUp() override {
GameObject do_not_use = mgr.new_object("DO_NOT_USE", "", {0, 0});
- do_not_use.add_component<Camera>(ivec2{1080, 720}, vec2{2000, 2000},
- Camera::Data{
+ do_not_use.add_component<Camera>(vec2{2000, 2000}, Camera::Data{
.bg_color = Color::WHITE,
.zoom = 1.0f,
});
diff --git a/src/test/RenderSystemTest.cpp b/src/test/RenderSystemTest.cpp
index 689a6d4..b984efe 100644
--- a/src/test/RenderSystemTest.cpp
+++ b/src/test/RenderSystemTest.cpp
@@ -128,8 +128,7 @@ TEST_F(RenderSystemTest, sorting_sprites) {
}
TEST_F(RenderSystemTest, Update) {
- entity1.add_component<Camera>(ivec2{100, 100}, vec2{100, 100},
- Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
+ entity1.add_component<Camera>(vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
{
vector<reference_wrapper<Sprite>> sprites = this->mgr.get_components_by_type<Sprite>();
ASSERT_EQ(sprites.size(), 4);
@@ -157,8 +156,7 @@ TEST_F(RenderSystemTest, Camera) {
EXPECT_NE(cameras.size(), 1);
}
{
- entity1.add_component<Camera>(ivec2{100, 100}, vec2{100, 100},
- Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
+ entity1.add_component<Camera>(vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
auto cameras = this->mgr.get_components_by_type<Camera>();
EXPECT_EQ(cameras.size(), 1);
@@ -167,8 +165,7 @@ TEST_F(RenderSystemTest, Camera) {
//TODO improve with newer version
}
TEST_F(RenderSystemTest, Color) {
- entity1.add_component<Camera>(ivec2{100, 100}, vec2{100, 100},
- Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
+ entity1.add_component<Camera>(vec2{100, 100}, Camera::Data{.bg_color = Color::WHITE, .zoom = 1.0f});
auto & sprite = this->mgr.get_components_by_id<Sprite>(entity1.id).front().get();
//ASSERT_NE(sprite.texture.texture.get(), nullptr);