]> git.localhorst.tv Git - l2e.git/blob - src/battle/PartyLayout.h
added interpretation of battle resources
[l2e.git] / src / battle / PartyLayout.h
1 /*
2  * PartyLayout.h
3  *
4  *  Created on: Aug 5, 2012
5  *      Author: holy
6  */
7
8 #ifndef BATTLE_PARTYLAYOUT_H_
9 #define BATTLE_PARTYLAYOUT_H_
10
11 #include "../geometry/Vector.h"
12
13 #include <cassert>
14 #include <vector>
15 #include <SDL.h>
16
17 namespace battle {
18
19 class PartyLayout {
20
21 public:
22         PartyLayout() { }
23
24 public:
25         std::vector<geometry::Vector<Uint8> >::size_type NumPositions() const { return positions.size(); }
26         template<class U>
27         void CalculatePositions(U width, U height, std::vector<geometry::Vector<U> > &dest) const {
28                 dest.clear();
29                 dest.reserve(positions.size());
30                 for (std::vector<geometry::Vector<Uint8> >::const_iterator i(positions.begin()), end(positions.end()); i != end; ++i) {
31                         dest.push_back(geometry::Vector<U>(
32                                         i->X() * width / 255,
33                                         i->Y() * height / 223
34                                         ));
35                 }
36         }
37         template<class U>
38         geometry::Vector<U> CalculatePosition(std::vector<geometry::Vector<Uint8> >::size_type index, U width, U height) const {
39                 assert(index >= 0 && index < positions.size());
40                 return geometry::Vector<U>(
41                                 positions[index].X() * width / 255,
42                                 positions[index].Y() * height / 223
43                                 );
44         }
45
46 public:
47         void AddPosition(const geometry::Vector<Uint8> &p) {
48                 positions.push_back(p);
49         }
50
51 private:
52         std::vector<geometry::Vector<Uint8> > positions;
53
54 };
55
56 }
57
58 #endif /* BATTLE_PARTYLAYOUT_H_ */