1 /** 2 ** aniinf.h - Animation information from 'shape_info.txt'. 3 ** 4 ** Written: 06/01/2008 - Marzo 5 **/ 6 7 #ifndef INCL_ANIINF_H 8 #define INCL_ANIINF_H 1 9 10 /* 11 Copyright (C) 2008 The Exult Team 12 13 This program is free software; you can redistribute it and/or 14 modify it under the terms of the GNU General Public License 15 as published by the Free Software Foundation; either version 2 16 of the License, or (at your option) any later version. 17 18 This program is distributed in the hope that it will be useful, 19 but WITHOUT ANY WARRANTY; without even the implied warranty of 20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 GNU General Public License for more details. 22 23 You should have received a copy of the GNU General Public License 24 along with this program; if not, write to the Free Software 25 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 26 */ 27 28 #include "baseinf.h" 29 #include "exult_constants.h" 30 31 #include <iosfwd> 32 33 class Shape_info; 34 35 /* 36 * Information about shape animations. 37 */ 38 class Animation_info : public Base_info { 39 public: 40 enum AniType { // Type of animation 41 FA_TIMESYNCHED = 0, // Frame based on current game ticks. 42 FA_HOURLY = 1, // Frame based on game hour. 43 FA_NON_LOOPING = 2, // Stop at last frame. 44 FA_LOOPING = 3, // Generic loop. 45 FA_RANDOM_FRAMES = 4 // Frames completely random. 46 }; 47 private: 48 AniType type; 49 int frame_count; // Frame count of each animation cycle 50 int frame_delay; // Delay multiplier between frames. 51 int sfx_delay; // Extra sfx delay, in frames. 52 int freeze_first; // % chance of advancing first frame of animation. 53 int recycle; // Repeat the last recycle frames when wrapping; 54 // all frames if zero. 55 public: 56 friend class Shape_info; 57 static Animation_info *create_from_tfa(int type, int nframes); 58 Animation_info() = default; 59 Animation_info(AniType t, int count = -1, int rec = 0, int freeze = 100, 60 int delay = 1, int sfxi = 0) { 61 set(t, count, rec, freeze, delay, sfxi); 62 } 63 // Read in from file. 64 bool read(std::istream &in, int version, Exult_Game game); 65 // Write out. 66 void write(std::ostream &out, int shapenum, Exult_Game game); 67 void set(AniType t, int count = -1, int rec = 0, int freeze = 100, 68 int delay = 1, int sfxi = 0) { 69 type = t; 70 frame_count = count; 71 frame_delay = delay; 72 sfx_delay = sfxi; 73 freeze_first = freeze; 74 recycle = rec; 75 } get_type()76 AniType get_type() const { 77 return type; 78 } set_type(AniType f)79 void set_type(AniType f) { 80 if (type != f) { 81 set_modified(true); 82 type = f; 83 } 84 } get_frame_count()85 int get_frame_count() const { 86 return frame_count; 87 } set_frame_count(int f)88 void set_frame_count(int f) { 89 if (frame_count != f) { 90 set_modified(true); 91 frame_count = f; 92 } 93 } get_frame_delay()94 int get_frame_delay() const { 95 return frame_delay; 96 } set_frame_delay(int f)97 void set_frame_delay(int f) { 98 if (frame_delay != f) { 99 set_modified(true); 100 frame_delay = f; 101 } 102 } get_sfx_delay()103 int get_sfx_delay() const { 104 return sfx_delay; 105 } set_sfx_delay(int f)106 void set_sfx_delay(int f) { 107 if (sfx_delay != f) { 108 set_modified(true); 109 sfx_delay = f; 110 } 111 } get_freeze_first_chance()112 int get_freeze_first_chance() const { 113 return freeze_first; 114 } set_freeze_first_chance(int f)115 void set_freeze_first_chance(int f) { 116 if (freeze_first != f) { 117 set_modified(true); 118 freeze_first = f; 119 } 120 } get_recycle()121 int get_recycle() const { 122 return recycle; 123 } set_recycle(int f)124 void set_recycle(int f) { 125 if (recycle != f) { 126 set_modified(true); 127 recycle = f; 128 } 129 } get_info_flag()130 static int get_info_flag() { 131 return 0x40; 132 } 133 enum { is_binary = 0, entry_size = 0 }; 134 }; 135 136 #endif 137