1 /***************************************************************************
2  *   Copyright (C) 2005-2019 by the FIFE team                              *
3  *   http://www.fifengine.net                                              *
4  *   This file is part of FIFE.                                            *
5  *                                                                         *
6  *   FIFE is free software; you can redistribute it and/or                 *
7  *   modify it under the terms of the GNU Lesser General Public            *
8  *   License as published by the Free Software Foundation; either          *
9  *   version 2.1 of the License, or (at your option) any later version.    *
10  *                                                                         *
11  *   This library is distributed in the hope that it will be useful,       *
12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
14  *   Lesser General Public License for more details.                       *
15  *                                                                         *
16  *   You should have received a copy of the GNU Lesser General Public      *
17  *   License along with this library; if not, write to the                 *
18  *   Free Software Foundation, Inc.,                                       *
19  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
20  ***************************************************************************/
21 
22 %module fife
23 %{
24 #include "view/visual.h"
25 %}
26 
27 namespace FIFE {
28 	class OverlayColors {
29 	public:
30 		OverlayColors();
31 		OverlayColors(ImagePtr image);
32 		OverlayColors(AnimationPtr animation);
33 		~OverlayColors();
34 		void setColorOverlayImage(ImagePtr image);
35 		ImagePtr getColorOverlayImage();
36 		void setColorOverlayAnimation(AnimationPtr animation);
37 		AnimationPtr getColorOverlayAnimation();
38 		void changeColor(const Color& source, const Color& target);
39 		const std::map<Color, Color>& getColors();
40 		void resetColors();
41 	};
42 
43 	class Visual2DGfx {
44 	public:
45 		virtual ~Visual2DGfx();
46 	private:
47 		Visual2DGfx();
48 	};
49 
50 	%apply std::vector<int32_t> &OUTPUT { std::vector<int32_t>& angles };
51 	class ObjectVisual: public Visual2DGfx {
52 	public:
53 		static ObjectVisual* create(Object* object);
54 		virtual ~ObjectVisual();
55 		void addStaticImage(uint32_t angle, int32_t image_index);
56 		int32_t getStaticImageIndexByAngle(int32_t angle);
57 		void addStaticColorOverlay(uint32_t angle, const OverlayColors& colors);
58 		OverlayColors* getStaticColorOverlay(int32_t angle);
59 		void removeStaticColorOverlay(int32_t angle);
60 		int32_t getClosestMatchingAngle(int32_t angle);
61 		void getStaticImageAngles(std::vector<int32_t>& angles);
62 	private:
63 		ObjectVisual();
64 	};
65 	%template(get2dGfxVisual) Object::getVisual<ObjectVisual>;
66 	%clear std::vector<int32_t> angles;
67 
68 	class InstanceVisual: public Visual2DGfx {
69 	public:
70 		static InstanceVisual* create(Instance* instance);
71 		virtual ~InstanceVisual();
72 		void setTransparency(uint8_t transparency);
73 		uint8_t getTransparency();
74 		void setVisible(bool visible);
75 		bool isVisible();
76 		void setStackPosition(int32_t stackposition);
77 		int32_t getStackPosition();
78 	private:
79 		InstanceVisual();
80 	};
81 	%template(get2dGfxVisual) Instance::getVisual<InstanceVisual>;
82 
83 	%apply std::vector<int32_t> &OUTPUT { std::vector<int32_t>& angles };
84 	class ActionVisual: public Visual2DGfx {
85 	public:
86 		static ActionVisual* create(Action* action);
87 		virtual ~ActionVisual();
88 		void addAnimation(uint32_t angle, AnimationPtr animationptr);
89 		AnimationPtr getAnimationByAngle(int32_t angle);
90 		void addAnimationOverlay(uint32_t angle, int32_t order, AnimationPtr animationptr);
91 		void removeAnimationOverlay(uint32_t angle, int32_t order);
92 		std::map<int32_t, AnimationPtr> getAnimationOverlay(int32_t angle);
93 		void addColorOverlay(uint32_t angle, const OverlayColors& colors);
94 		OverlayColors* getColorOverlay(int32_t angle);
95 		void removeColorOverlay(int32_t angle);
96 		void addColorOverlay(uint32_t angle, int32_t order, const OverlayColors& colors);
97 		OverlayColors* getColorOverlay(int32_t angle, int32_t order);
98 		void removeColorOverlay(int32_t angle, int32_t order);
99 		void getActionImageAngles(std::vector<int32_t>& angles);
100 		void convertToOverlays(bool color);
101 		bool isAnimationOverlay();
102 		bool isColorOverlay();
103 	private:
104 		ActionVisual();
105 	};
106 	%template(get2dGfxVisual) Action::getVisual<ActionVisual>;
107 }
108