1 /*
2     Copyright (C) 2010 Andrew Caudwell (acaudwell@gmail.com)
3 
4     This program is free software; you can redistribute it and/or
5     modify it under the terms of the GNU General Public License
6     as published by the Free Software Foundation; either version
7     3 of the License, or (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #ifndef FILE_KEY_H
19 #define FILE_KEY_H
20 
21 #include "core/display.h"
22 #include "core/vectors.h"
23 #include "core/fxfont.h"
24 
25 #include "file.h"
26 
27 #include <vector>
28 #include <algorithm>
29 
30 class FileKeyEntry {
31     FXFont font;
32     vec3 colour;
33     std::string ext;
34     std::string display_ext;
35     float alpha;
36     float brightness;
37     int count;
38     float pos_y;
39     float src_y;
40     float dest_y;
41     float move_elapsed;
42     float left_margin;
43     float width;
44     float height;
45     vec2 pos;
46     vec2 shadow;
47     bool show;
48 public:
49     FileKeyEntry(const FXFont& font, const std::string& ext, const vec3& colour);
50 
51     const vec3& getColour() const;
52     const std::string& getExt() const;
53 
54     void setDestY(float dest_y);
55 
56     void colourize();
57 
58     void inc();
59     void dec();
60 
61     void setShow(bool show);
62 
63     int getCount() const;
64     void setCount(int count);
65 
66     bool isNew() const;
67     bool isFinished() const;
68 
69     void logic(float dt);
70 
71     void draw();
72 };
73 
74 class FileKey {
75     std::vector<FileKeyEntry*> active_keys;
76     std::map<std::string, FileKeyEntry*> keymap;
77 
78     FXFont font;
79     float update_interval;
80     float interval_remaining;
81     bool show;
82 public:
83     FileKey();
84     ~FileKey();
85     FileKey(float update_interval);
86 
87     void setShow(bool show);
88 
89     void clear();
90 
91     void colourize();
92 
93     void inc(RFile* file);
94     void dec(RFile* file);
95 
96     void logic(float dt);
97 
98     void draw();
99 };
100 
101 #endif
102