PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/engines/sherlock/scalpel/tsage/logo.h

http://github.com/scummvm/scummvm
C Header | 250 lines | 115 code | 39 blank | 96 comment | 0 complexity | 00d0540c6a8e4b9613267cf5ca58e92e MD5 | raw file
Possible License(s): GPL-3.0, LGPL-2.1, GPL-2.0
  1. /* ScummVM - Graphic Adventure Engine
  2. *
  3. * ScummVM is the legal property of its developers, whose names
  4. * are too numerous to list here. Please refer to the COPYRIGHT
  5. * file distributed with this source distribution.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. *
  21. */
  22. #ifndef SHERLOCK_SCALPEL_TSAGE_LOGO_H
  23. #define SHERLOCK_SCALPEL_TSAGE_LOGO_H
  24. #include "common/scummsys.h"
  25. #include "common/array.h"
  26. #include "common/file.h"
  27. #include "common/list.h"
  28. #include "common/str.h"
  29. #include "common/str-array.h"
  30. #include "common/util.h"
  31. #include "graphics/surface.h"
  32. #include "sherlock/scalpel/tsage/resources.h"
  33. #include "sherlock/screen.h"
  34. namespace Sherlock {
  35. namespace Scalpel {
  36. class ScalpelEngine;
  37. namespace TsAGE {
  38. class ObjectSurface : public Surface {
  39. public:
  40. Common::Point _centroid;
  41. public:
  42. ObjectSurface() : Surface() {}
  43. ~ObjectSurface() override {}
  44. };
  45. class Visage {
  46. private:
  47. Common::SeekableReadStream *_stream;
  48. /**
  49. * Translates a raw image resource into a graphics surface
  50. */
  51. void surfaceFromRes(ObjectSurface &s);
  52. public:
  53. static TLib *_tLib;
  54. int _resNum;
  55. int _rlbNum;
  56. public:
  57. Visage();
  58. ~Visage();
  59. /**
  60. * Set the visage number
  61. */
  62. void setVisage(int resNum, int rlbNum = 9999);
  63. /**
  64. * Clear the visage
  65. */
  66. void clear();
  67. /**
  68. * Get a frame from the visage
  69. */
  70. void getFrame(ObjectSurface &s, int frameNum);
  71. /**
  72. * Return the number of frames
  73. */
  74. int getFrameCount() const;
  75. /**
  76. * Returns whether the visage is loaded
  77. */
  78. bool isLoaded() const;
  79. };
  80. class Object {
  81. private:
  82. Visage _visage;
  83. uint32 _updateStartFrame;
  84. bool _isAnimating;
  85. bool _finished;
  86. uint32 _walkStartFrame;
  87. int _angle;
  88. int _changeCtr;
  89. int _majorDiff, _minorDiff;
  90. Common::Point _moveDelta;
  91. Common::Point _moveSign;
  92. /**
  93. * Return the next frame when the object is animating
  94. */
  95. int changeFrame();
  96. /**
  97. * Gets the next frame in the sequence
  98. */
  99. int getNewFrame();
  100. /**
  101. * Calculate the angle between the current position and a designated destination
  102. */
  103. void calculateMoveAngle();
  104. /**
  105. * Handle any object movement
  106. */
  107. void move();
  108. /**
  109. * Returns whether not to make any movement
  110. */
  111. bool dontMove() const;
  112. /**
  113. * Ends any current movement
  114. */
  115. void endMove();
  116. public:
  117. static ScalpelEngine *_vm;
  118. Common::Point _position;
  119. Common::Point _destination;
  120. Common::Rect _oldBounds;
  121. int _frame;
  122. int _numFrames;
  123. int _frameChange;
  124. public:
  125. Object();
  126. /**
  127. * Load the data for the object
  128. */
  129. void setVisage(int visage, int strip);
  130. /**
  131. * Sets whether the object is animating
  132. */
  133. void setAnimMode(bool isAnimating);
  134. /**
  135. * Starts an object moving to a given destination
  136. */
  137. void setDestination(const Common::Point &pt);
  138. /**
  139. * Returns true if an animation is ended
  140. */
  141. bool isAnimEnded() const;
  142. /**
  143. * Return true if object is moving
  144. */
  145. bool isMoving() const;
  146. /**
  147. * Erase the area the object was previously drawn at, by restoring the background
  148. */
  149. void erase();
  150. /**
  151. * Update the frame
  152. */
  153. void update();
  154. /**
  155. * Remove an object from being displayed
  156. */
  157. void remove() { _visage.clear(); }
  158. };
  159. struct AnimationFrame {
  160. int frame;
  161. int x;
  162. int y;
  163. };
  164. class Logo {
  165. private:
  166. ScalpelEngine *_vm;
  167. TLib _lib;
  168. int _counter, _frameCounter;
  169. bool _finished;
  170. byte _originalPalette[PALETTE_SIZE];
  171. byte _palette1[PALETTE_SIZE];
  172. byte _palette2[PALETTE_SIZE];
  173. byte _palette3[PALETTE_SIZE];
  174. Object _objects[4];
  175. uint _waitFrames;
  176. uint32 _waitStartFrame;
  177. int _animateObject;
  178. uint32 _animateStartFrame;
  179. uint _animateFrameDelay;
  180. const AnimationFrame *_animateFrames;
  181. uint _animateFrame;
  182. Logo(ScalpelEngine *vm);
  183. ~Logo();
  184. void nextFrame();
  185. bool finished() const;
  186. /**
  187. * Wait for a number of frames. Note that the frame count in _events is
  188. * not the same as the number of calls to nextFrame().
  189. */
  190. void waitFrames(uint frames);
  191. /**
  192. * Start an animation sequence. Used for sequences that are described
  193. * one frame at a time because they do unusual things, or run at
  194. * unusual rates.
  195. */
  196. void startAnimation(uint object, uint frameDelay, const AnimationFrame *frames);
  197. /**
  198. * Load the background for the scene
  199. */
  200. void loadBackground();
  201. /**
  202. * Fade from the current palette to a new one
  203. */
  204. void fade(const byte palette[PALETTE_SIZE], int step = 6);
  205. public:
  206. static bool show(ScalpelEngine *vm);
  207. };
  208. } // end of namespace TsAGE
  209. } // end of namespace Scalpel
  210. } // end of namespace Sherlock
  211. #endif