1 /** @file finaleanimwidget.h InFine animation system, FinaleAnimWidget. 2 * 3 * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi> 4 * @authors Copyright © 2005-2014 Daniel Swanson <danij@dengine.net> 5 * 6 * @par License 7 * GPL: http://www.gnu.org/licenses/gpl.html 8 * 9 * <small>This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by the 11 * Free Software Foundation; either version 2 of the License, or (at your 12 * option) any later version. This program is distributed in the hope that it 13 * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 15 * Public License for more details. You should have received a copy of the GNU 16 * General Public License along with this program; if not, write to the Free 17 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 18 * 02110-1301 USA</small> 19 */ 20 21 #ifndef DENG_UI_INFINE_FINALEANIMWIDGET_H 22 #define DENG_UI_INFINE_FINALEANIMWIDGET_H 23 24 #include <QList> 25 #include <doomsday/world/Material> 26 #include "finalewidget.h" 27 28 /** 29 * Finale animation widget. Colored rectangles or image sequence animations. 30 * 31 * @ingroup infine 32 */ 33 class FinaleAnimWidget : public FinaleWidget 34 { 35 public: 36 /** 37 * Describes a frame in the animation sequence. 38 */ 39 struct Frame 40 { 41 enum Type 42 { 43 PFT_MATERIAL, 44 PFT_PATCH, 45 PFT_RAW, /// "Raw" graphic or PCX lump. 46 PFT_XIMAGE /// External graphics resource. 47 }; 48 49 int tics; 50 Type type; 51 struct Flags { 52 char flip:1; 53 } flags; 54 union { 55 world::Material *material; 56 patchid_t patch; 57 lumpnum_t lumpNum; 58 DGLuint tex; 59 } texRef; 60 short sound; 61 62 Frame(); 63 ~Frame(); 64 }; 65 typedef QList<Frame *> Frames; 66 67 public: 68 FinaleAnimWidget(de::String const &name); 69 virtual ~FinaleAnimWidget(); 70 71 /// @todo Observe instead. 72 bool animationComplete() const; 73 74 FinaleAnimWidget &setLooping(bool yes = true); 75 76 int newFrame(Frame::Type type, int tics, void *texRef, short sound, bool flagFlipH); 77 78 Frames const &allFrames() const; 79 FinaleAnimWidget &clearAllFrames(); 80 frameCount()81 inline int frameCount() const { return allFrames().count(); } 82 83 FinaleAnimWidget &resetAllColors(); 84 85 animator_t const *color() const; 86 FinaleAnimWidget &setColorAndAlpha(de::Vector4f const &newColorAndAlpha, int steps = 0); 87 FinaleAnimWidget &setColor(de::Vector3f const &newColor, int steps = 0); 88 FinaleAnimWidget &setAlpha(float newAlpha, int steps = 0); 89 90 animator_t const *edgeColor() const; 91 FinaleAnimWidget &setEdgeColorAndAlpha(de::Vector4f const &newColorAndAlpha, int steps = 0); 92 FinaleAnimWidget &setEdgeColor(de::Vector3f const &newColor, int steps = 0); 93 FinaleAnimWidget &setEdgeAlpha(float newAlpha, int steps = 0); 94 95 animator_t const *otherColor() const; 96 FinaleAnimWidget &setOtherColorAndAlpha(de::Vector4f const &newColorAndAlpha, int steps = 0); 97 FinaleAnimWidget &setOtherColor(de::Vector3f const &newColor, int steps = 0); 98 FinaleAnimWidget &setOtherAlpha(float newAlpha, int steps = 0); 99 100 animator_t const *otherEdgeColor() const; 101 FinaleAnimWidget &setOtherEdgeColorAndAlpha(de::Vector4f const &newColorAndAlpha, int steps = 0); 102 FinaleAnimWidget &setOtherEdgeColor(de::Vector3f const &newColor, int steps = 0); 103 FinaleAnimWidget &setOtherEdgeAlpha(float newAlpha, int steps = 0); 104 105 protected: 106 #ifdef __CLIENT__ 107 void draw(de::Vector3f const &offset); 108 #endif 109 void runTicks(/*timespan_t timeDelta*/); 110 111 private: 112 DENG2_PRIVATE(d) 113 }; 114 115 typedef FinaleAnimWidget::Frame FinaleAnimWidgetFrame; 116 117 #endif // DENG_UI_INFINE_FINALEANIMWIDGET_H 118