2 Copyright (c) 2007 Paolo Capriotti <p.capriotti@gmail.com>
3 (c) 2007 Maurizio Monge <maurizio.monge@kdemail.net>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
11 #ifndef HLVARIANT__UNWRAPPEDGRAPHICALAPI_H
12 #define HLVARIANT__UNWRAPPEDGRAPHICALAPI_H
14 #include "graphicalapi.h"
15 #include "variantdata.h"
20 * This class moves the interface that will be used by the animator to modify
21 * tagua graphics into the variant's semantics.
23 template <typename Variant
>
24 class UnwrappedGraphicalAPI
{
25 GraphicalAPI
* m_graphical_api
;
27 typedef typename VariantData
<Variant
>::GameState GameState
;
28 typedef typename VariantData
<Variant
>::Piece Piece
;
30 typedef boost::shared_ptr
<UnwrappedGraphicalAPI
> Ptr
;
32 UnwrappedGraphicalAPI(GraphicalAPI
* interface
)
33 : m_graphical_api(interface
) {
36 virtual ~UnwrappedGraphicalAPI(){}
38 virtual const PointConverter
* converter() {
39 return m_graphical_api
->converter();
42 virtual const GameState
* position() {
43 const WrappedPosition
<Variant
> *p
= dynamic_cast<const WrappedPosition
<Variant
>*>(m_graphical_api
->position().get());
48 MISMATCH(m_graphical_api
->position(), WrappedPosition
<Variant
>);
53 virtual NamedSprite
setPiece(const Point
& p
, const Piece
& piece
, bool show
) {
54 WrappedPiece
<Variant
> wpiece(piece
);
55 return m_graphical_api
->setPiece(p
, &wpiece
, show
);
58 virtual NamedSprite
createPiece(const Point
& p
, const Piece
& piece
, bool show
) {
59 WrappedPiece
<Variant
> wpiece(piece
);
60 return m_graphical_api
->createPiece(p
, &wpiece
, show
);
63 virtual void setSprite(const Point
& p
, const NamedSprite
& s
) {
64 m_graphical_api
->setSprite(p
, s
);
67 virtual NamedSprite
getSprite(const Point
& p
) {
68 return m_graphical_api
->getSprite(p
);
71 virtual NamedSprite
takeSprite(const Point
& p
) {
72 return m_graphical_api
->takeSprite(p
);
75 virtual int poolSize(int pool
) const {
76 return m_graphical_api
->poolSize(pool
);
79 virtual NamedSprite
insertPoolPiece(int pool
, int index
, const Piece
& piece
) {
80 WrappedPiece
<Variant
> wpiece(piece
);
81 return m_graphical_api
->insertPoolPiece(pool
, index
, &wpiece
);
84 virtual NamedSprite
getPoolSprite(int pool
, int index
) {
85 return m_graphical_api
->getPoolSprite(pool
, index
);
88 virtual void removePoolSprite(int pool
, int index
) {
89 m_graphical_api
->removePoolSprite(pool
, index
);
92 virtual NamedSprite
takePoolSprite(int pool
, int index
) {
93 return m_graphical_api
->takePoolSprite(pool
, index
);
96 virtual std::pair
<int, int> droppedPoolPiece() {
97 return m_graphical_api
->droppedPoolPiece();
100 virtual AnimationPtr
animate(const Animate::Scheme
& scheme
, Animate::AnimationType type
= Animate::Normal
) {
101 return m_graphical_api
->animate(scheme
, type
);
104 GraphicalAPI
* inner() const { return m_graphical_api
; }
109 #endif // HLVARIANT__UNWRAPPEDGRAPHICALAPI_H