HoverRace  2.0
AvatarGallery.h
Go to the documentation of this file.
1 
2 // AvatarGallery.h
3 //
4 // Copyright (c) 2016 Michael Imamura.
5 //
6 // Licensed under GrokkSoft HoverRace SourceCode License v1.0(the "License");
7 // you may not use this file except in compliance with the License.
8 //
9 // A copy of the license should have been attached to the package from which
10 // you have taken this file. If you can not find the license you can not use
11 // this file.
12 //
13 //
14 // The author makes no representations about the suitability of
15 // this software for any purpose. It is provided "as is" "AS IS",
16 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
17 // implied.
18 //
19 // See the License for the specific language governing permissions
20 // and limitations under the License.
21 
22 #pragma once
23 
24 #include "../Display/Res.h"
25 #include "../Util/OS.h"
26 
27 #if defined(_WIN32) && defined(HR_ENGINE_SHARED)
28 # ifdef MR_ENGINE
29 # define MR_DllDeclare __declspec( dllexport )
30 # else
31 # define MR_DllDeclare __declspec( dllimport )
32 # endif
33 #else
34 # define MR_DllDeclare
35 #endif
36 
37 namespace HoverRace {
38  namespace Display {
39  class Texture;
40  }
41 }
42 
43 namespace HoverRace {
44 namespace Player {
45 
51 {
52 public:
53  AvatarGallery(const Util::OS::path_t &path = { });
54 
55 public:
56  void Reload();
57 
58 public:
59  bool IsEmpty() const { return avatars.empty(); }
60 
61  static const std::string &GetDefaultAvatarName();
62 
63 public:
64  std::shared_ptr<Display::Res<Display::Texture>> FindName(
65  const std::string &s) const;
66 
67 private:
68  using avatars_t = std::unordered_map<
69  std::string,
70  std::shared_ptr<Display::Res<Display::Texture>>>;
71 public:
72  // STL-like iteration, so we can use range-for.
73  using iterator = avatars_t::iterator;
74  using const_iterator = avatars_t::const_iterator;
75  using value_type = avatars_t::value_type;
76  const_iterator begin() const { return avatars.begin(); }
77  iterator begin() { return avatars.begin(); }
78  const_iterator end() const { return avatars.end(); }
79  iterator end() { return avatars.end(); }
80 
81 private:
84 };
85 
86 } // namespace Player
87 } // namespace HoverRace
88 
89 #undef MR_DllDeclare
boost::filesystem::path path_t
Definition: OS.h:57
Definition: Announcement.h:24