From 1da356d8a64c45c99871aca156ee9fdd3e10ec15 Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Wed, 27 Sep 2023 08:03:04 -0400 Subject: Simplification of the Theme system with a more OO model --- themes/src/autumn/AutumnTheme.cpp | 14 +++++++++++++- themes/src/autumn/AutumnTheme.hpp | 10 ++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'themes/src/autumn') diff --git a/themes/src/autumn/AutumnTheme.cpp b/themes/src/autumn/AutumnTheme.cpp index affcc00..c6431a1 100644 --- a/themes/src/autumn/AutumnTheme.cpp +++ b/themes/src/autumn/AutumnTheme.cpp @@ -8,6 +8,17 @@ namespace const int NUM_HILLS = 3; } +AutumnTheme::AutumnTheme(Renderer2d* renderer) + : renderer{renderer} +{ + load(renderer); +} + +AutumnTheme::~AutumnTheme() +{ + unload(); +} + void AutumnTheme::load(Renderer2d* renderer) { renderer->clearColor = Vector4(252, 210, 153, 255).toNormalizedColor(); auto lr = tree.load(renderer); @@ -45,7 +56,8 @@ void AutumnTheme::update(f32 dtSeconds) { leafParticles.update(dtSeconds); } -void AutumnTheme::render(Renderer2d* renderer) { +void AutumnTheme::render() { + renderer->render(); background->render(); background_hill->render(); tree.render(renderer); diff --git a/themes/src/autumn/AutumnTheme.hpp b/themes/src/autumn/AutumnTheme.hpp index 2d9958c..41df04c 100644 --- a/themes/src/autumn/AutumnTheme.hpp +++ b/themes/src/autumn/AutumnTheme.hpp @@ -4,6 +4,7 @@ #include "TreeShape.h" #include "LeafParticleRender.h" #include "../types.h" +#include "../theme.h" #include #include @@ -11,7 +12,10 @@ struct Renderer2d; class RectangularGradient; class Circleish; -struct AutumnTheme { +class AutumnTheme : public Theme { +public: + AutumnTheme(Renderer2d* renderer); + ~AutumnTheme(); TreeShape tree; LeafParticleRender leafParticles; RectangularGradient* background; @@ -20,8 +24,10 @@ struct AutumnTheme { void load(Renderer2d* renderer); void update(f32 dtSeconds); - void render(Renderer2d* renderer); + void render(); void unload(); +private: + Renderer2d* renderer; }; #endif -- cgit v1.2.1