From: Mikko Rasa Date: Fri, 21 Jun 2019 14:48:32 +0000 (+0300) Subject: Make the default constructor of Resources protected X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=08fa4d11a07a52e62eb4e30730d2a2b9cdcb568d;p=libs%2Fdemoscene.git 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. --- 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();