]> git.tdb.fi Git - libs/demoscene.git/blob - source/resources.cpp
1742f06d41694cdb689b2db6be0a3b17be617d5a
[libs/demoscene.git] / source / resources.cpp
1 #include <msp/fs/dir.h>
2 #include <msp/fs/stat.h>
3 #include "resources.h"
4
5 using namespace std;
6
7 namespace Msp {
8 namespace DemoScene {
9
10 Resources::Resources(const string &pack_name):
11         ui_font(0),
12         ui_text_technique(0)
13 {
14         set_default_texture_anisotropy(8);
15         set_srgb_conversion(true);
16
17         FS::Path data_dir = "data";
18         if(FS::exists(data_dir))
19         {
20                 dir_source.add_directory(data_dir);
21                 add_source(dir_source);
22                 for(const auto &c: FS::list_filtered(data_dir, "\\.mdc$"))
23                         load(*this, (data_dir/c).str());
24         }
25         else
26         {
27                 pack_source.add_pack_file(pack_name);
28                 add_source(pack_source);
29         }
30 }
31
32 const GL::Font &Resources::get_ui_font() const
33 {
34         if(!ui_font)
35                 throw runtime_error("no ui font");
36         return *ui_font;
37 }
38
39 const GL::Technique &Resources::get_ui_text_technique() const
40 {
41         if(!ui_text_technique)
42                 throw runtime_error("no ui text technique");
43         return *ui_text_technique;
44 }
45
46 void Resources::set_ui_text_resources(const string &font, const string &tech)
47 {
48         ui_font = &get<GL::Font>(font);
49         ui_text_technique = &get<GL::Technique>(tech);
50 }
51
52 } // namespace DemoScene
53 } // namespace Msp