From 08fa4d11a07a52e62eb4e30730d2a2b9cdcb568d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 21 Jun 2019 17:48:32 +0300 Subject: [PATCH] Make the default constructor of Resources protected ... instead of private. This enables derived classes to call the default constructor and then add their own types before initializing the sources. --- source/resources.cpp | 22 ++++++++++++++++------ source/resources.h | 4 ++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/source/resources.cpp b/source/resources.cpp index f44d8c1..c70e0a1 100644 --- a/source/resources.cpp +++ b/source/resources.cpp @@ -12,16 +12,17 @@ void init_data(DataFile::BuiltinSource &); Resources::Resources() { - add_source(get_builtin_source()); + init(); } -Resources::Resources(const string &pack_name): - ui_font(0), - ui_text_technique(0) +Resources::Resources(const string &pack_name) { - set_default_texture_anisotropy(8); - set_srgb_conversion(true); + init(); + init_sources(pack_name); +} +void Resources::init_sources(const string &pack_name) +{ FS::Path data_dir = "data"; if(FS::exists(data_dir)) { @@ -35,6 +36,15 @@ Resources::Resources(const string &pack_name): pack_source.add_pack_file(pack_name); add_source(pack_source); } +} + +void Resources::init() +{ + ui_font = 0; + ui_text_technique = 0; + + set_default_texture_anisotropy(8); + set_srgb_conversion(true); add_source(get_builtin_source()); } diff --git a/source/resources.h b/source/resources.h index fc7e7d2..ed0323b 100644 --- a/source/resources.h +++ b/source/resources.h @@ -19,11 +19,15 @@ private: const Msp::GL::Font *ui_font; const Msp::GL::Technique *ui_text_technique; +protected: Resources(); public: Resources(const std::string &); +protected: + void init_sources(const std::string &); private: + void init(); static const DataFile::CollectionSource &get_builtin_source(); public: static Resources &get_builtins(); -- 2.45.2