aAnimObject.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #define AANIMOBJECT_CPP
  2. /*************************************************************************************************\
  3. aAnimObject.cpp : Implementation of the aAnimObject component.
  4. //---------------------------------------------------------------------------//
  5. // Copyright (C) Microsoft Corporation. All rights reserved. //
  6. //===========================================================================//
  7. \*************************************************************************************************/
  8. #include "aAnimObject.h"
  9. #include "mclib.h"
  10. aAnimObject::aAnimObject( )
  11. {
  12. }
  13. //-------------------------------------------------------------------------------------------------
  14. aAnimObject::~aAnimObject()
  15. {
  16. }
  17. aAnimObject& aAnimObject::operator =( const aAnimObject& src )
  18. {
  19. if ( &src != this )
  20. {
  21. aObject::operator =( src );
  22. animInfo = src.animInfo;
  23. }
  24. return *this;
  25. }
  26. int aAnimObject::init( FitIniFile* file, const char* blockName, DWORD neverFlush )
  27. {
  28. aObject::init( file, blockName, neverFlush );
  29. long color = 0xffffffff;
  30. if ( NO_ERR == file->readIdLong( "Color", color ) )
  31. {
  32. setColor( color );
  33. }
  34. else
  35. setColor( 0xffffffff );
  36. char animName[256];
  37. file->readIdString( "Animation", animName, 255 );
  38. if ( NO_ERR == file->seekBlock( animName ) )
  39. animInfo.init( file, "" );
  40. animInfo.begin();
  41. return 0;
  42. }
  43. void aAnimObject::update()
  44. {
  45. animInfo.update();
  46. }
  47. void aAnimObject::render( )
  48. {
  49. if ( !isShowing() )
  50. return;
  51. long color = animInfo.getColor();
  52. float xNewOffset = animInfo.getXDelta()+.5f;
  53. float yNewOffset = animInfo.getYDelta()+.5f;
  54. move( xNewOffset, yNewOffset );
  55. setColor( color );
  56. float fScaleX = animInfo.getScaleX();
  57. float fScaleY = animInfo.getScaleY();
  58. if ( fScaleX != 1.0 || fScaleY != 1.0 )
  59. {
  60. float oldWidth = width()+.5f;
  61. float oldHeight = height()+.5f;;
  62. float oldLeft = globalX();
  63. float oldTop = globalY();
  64. float scaleX = .5 * fScaleX * width();
  65. float scaleY = .5 * fScaleY * height();
  66. float midX = globalX() + .5 * width();
  67. float midY = globalY() + .5 * height();
  68. float newLeft = midX - scaleX;
  69. float newTop = midY - scaleY;
  70. moveToNoRecurse( newLeft, newTop );
  71. resize( fScaleX * width(), fScaleY * height() );
  72. aObject::render();
  73. resize( oldWidth, oldHeight );
  74. moveToNoRecurse( oldLeft, oldTop );
  75. }
  76. else
  77. aObject::render();
  78. move( -xNewOffset, -yNewOffset );
  79. }
  80. void aAnimObject::end()
  81. {
  82. animInfo.end();
  83. }
  84. //*************************************************************************************************
  85. // end of file ( aAnimObject.cpp )