Initial commit, includes Lua with broken Luabind as a backup for branching purposes
[terrastrategy.git] / src / gui / cursor.h
blob8398a622158ab925034871bc86c7182c7de7081b
1 //
2 // Copyright (C) 2008 by Martin Moracek
3 //
4 // This program is free software; you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation; either version 2 of the License, or
7 // (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.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /**
20 * @file cursor.h
22 * Ble.
25 #pragma once
27 #include <string>
28 #include <vector>
29 #include <boost/smart_ptr.hpp>
31 #include "platform.h"
33 #ifdef PLATFORM_MSVC
34 # include <unordered_map>
35 #else /* PLATFORM_MSVC */
36 # include <tr1/unordered_map>
37 #endif /* PLATFORM_MSVC */
39 #include "cpair.h"
41 #include "renderer/buffers.h"
42 #include "renderer/effect.h"
44 #include "math/vector.h"
46 class TiXmlElement;
48 namespace tre {
50 class Cursor {
51 public:
52 AttribBufPtr attribs;
53 IndexBufPtr indices;
54 EffectPtr effect;
55 EffectVars vars;
57 public:
58 void Rescale(const Vector2f & scale, Float2Vector & verts);
60 void LoadFromXml(TiXmlElement & root, const Vector2f & scale,
61 Float2Vector & verts, Float2Vector & coords);
63 private:
64 Vector2f baseSize_;
65 Vector2f baseOffset_;
68 class CursorSet;
70 typedef boost::shared_ptr<CursorSet> CursorSetPtr;
71 typedef boost::weak_ptr<CursorSet> CursorSetRef;
73 class CursorSetFactory {
74 public:
75 const CursorSetPtr CreateInstance(const std::string & filename,
76 const Vector2f & scale);
77 const CursorSetPtr CreateInstance(TiXmlElement & root,
78 const Vector2f & scale);
80 private:
81 typedef std::tr1::unordered_map<std::string, CursorSetRef> CursorMap;
83 private:
84 CursorMap cursorMap_;
87 class CursorSet {
88 public:
89 static CursorSetFactory & Factory(void)
91 static CursorSetFactory fac;
92 return fac;
95 public:
96 typedef cpair<std::string, Cursor> CursorPair;
97 typedef std::vector<CursorPair> CursorVector;
99 public:
100 const Cursor * GetCursor(const std::string & name) const;
102 void OnGuiResize(const Vector2f & scale);
104 void LoadFromXml(TiXmlElement & root, const Vector2f & scale);
106 private:
107 CursorVector cursors_;
109 AttribBufPtr attribs_;
110 ushort bufSize_;