home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / flash078.zip / flashsource-r0_7_8.zip / FDisplay.cpp < prev    next >
C/C++ Source or Header  |  2001-08-02  |  4KB  |  158 lines

  1. #include "FBase.h"
  2. #include "FDisplay.h"
  3. #include <iostream>
  4. #include <strstream>
  5.  
  6.  
  7. FlashTagPlaceObject::FlashTagPlaceObject(UWORD _charID,UWORD _depth, FlashMatrix &m)
  8. : characterID(_charID), depth(_depth), matrix(m), hascfx(false)
  9. {
  10. }
  11.  
  12. FlashTagPlaceObject::FlashTagPlaceObject(UWORD _charID,UWORD _depth, FlashMatrix &m, FlashColorTransform &c)
  13. : characterID(_charID), depth(_depth), matrix(m), hascfx(true)
  14. {
  15.   cfx = c;
  16. }
  17.  
  18. std::ostream& operator<<(std::ostream& out, FlashTagPlaceObject &data)
  19. {
  20.     std::ostrstream s;
  21.     s.write((const char*)&data.characterID,2);
  22.     s.write((const char*)&data.depth,2);
  23.     s << data.matrix;
  24.     if(data.hascfx) { s << data.cfx; }
  25.     
  26.     out << FlashTagHeader(4, s.pcount());
  27.     out.write(s.rdbuf()->str(), s.pcount());
  28.     return out;
  29. }
  30. std::istream& operator>>(std::istream& in, FlashTagPlaceObject &data)
  31. {
  32.     std::streampos start = in.tellg();
  33.     in.read((char*)&data.characterID,2);
  34.     in.read((char*)&data.depth,2);
  35.     in >> data.matrix;
  36.     
  37.     if(data.importsize + start != (UDWORD)in.tellg())
  38.     {
  39.         data.hascfx = true;
  40.         in >> data.cfx;
  41.     }
  42.     return in;
  43. }
  44.  
  45. std::ostream& operator<<(std::ostream& out, FlashTagRemoveObject &data)
  46. {
  47.     out << FlashTagHeader(5,4);
  48.     WRITE_UWORD(data.charID);
  49.     WRITE_UWORD(data.depth);
  50.     return out;
  51. }
  52.  
  53. std::istream& operator>>(std::istream& in, FlashTagRemoveObject &data)
  54. {
  55.     READ_UWORD(data.charID);
  56.     READ_UWORD(data.depth);
  57.     return in;
  58. }
  59. std::ostream& operator<<(std::ostream& out, FlashTagPlaceObject2 &data)
  60. {
  61.     std::strstream o;
  62.     BitBuffer b;
  63.     b.Write(0,1); // CLIP ACTIONS
  64.     b.Write(data.hasClipDepth,1); 
  65.     b.Write(data.hasName,1);
  66.     b.Write(data.hasRatio,1);
  67.     b.Write(data.hasColorTransform,1);
  68.     b.Write(data.hasMatrix,1);
  69.     b.Write(data.hasCharID,1);
  70.     b.Write(data.hasMove,1);
  71.     if(data.hasColorTransform) data.cfx.SetTagVersion(2);
  72.     o << b;
  73.     o.write((char*)&data.depth,2);
  74.     if(data.hasCharID) o.write((char*)&data.charID,2);
  75.     if(data.hasMatrix) o << data.matrix;
  76.     if(data.hasColorTransform) o << data.cfx;
  77.     if(data.hasRatio) o.write((char*)&data.ratio,2);
  78.     if(data.hasName) { o.write(data.name.c_str(),data.name.size()); o << (char)0; }
  79.     if(data.hasClipDepth) o.write((char*)&data.clipDepth,2);
  80.  
  81.     out << FlashTagHeader(26,o.rdbuf()->pcount());
  82.     out.write((char*)o.rdbuf()->str(),o.rdbuf()->pcount());
  83.     
  84.     return out;
  85. }
  86. std::istream& operator>>(std::istream& in, FlashTagPlaceObject2 &data)
  87. {
  88.     BitStreamIn b(&in);
  89.     unsigned char hasclipdepth;
  90.     b.Read(hasclipdepth,1); // CLIP ACTIONS
  91.     unsigned char tmp;
  92.     b.Read(tmp,1); // RESERVED FOR FUTURE USE
  93.     unsigned  hasname;
  94.     b.Read(hasname,1);
  95.     unsigned char hasratio;
  96.     b.Read(hasratio,1);
  97.     unsigned char hascfx;
  98.     b.Read(hascfx,1);
  99.     unsigned char hasmatrix;
  100.     b.Read(hasmatrix,1);
  101.     unsigned char hasid;
  102.     b.Read(hasid,1);
  103.     unsigned char move;
  104.     b.Read(move,1);
  105.  
  106.     data.hasName = (hasname == 1);
  107.     data.hasCharID = (hasid == 1);
  108.     data.hasMove = (move == 1);
  109.     data.hasMatrix = (hasmatrix == 1);
  110.     data.hasColorTransform = (hascfx == 1);
  111.     data.hasRatio = (hasratio == 1);
  112.     data.hasClipDepth = (hasclipdepth == 1);
  113.     
  114.     b.Align();
  115.  
  116.     in.read((char*)&data.depth,2);
  117.     if(hasid)
  118.     {
  119.         in.read((char*)&data.charID,2);
  120.     }
  121.     if(hasmatrix)
  122.     {
  123.         in >> data.matrix;
  124.     }
  125.     if(hascfx)
  126.     {
  127.         data.cfx.SetTagVersion(2);
  128.         in >> data.cfx;
  129.     }
  130.     if(hasratio)
  131.     {
  132.         in.read((char*)&data.ratio,2);
  133.     }
  134.     if(hasname) 
  135.     { 
  136.         unsigned int i;
  137.         while((i = in.get()) != 0)
  138.         {
  139.             data.name+=(char)i;
  140.         }                
  141.     }
  142.     return in;
  143. }
  144.  
  145.  
  146. std::ostream& operator<<(std::ostream& out, FlashTagRemoveObject2 &data)
  147. {
  148.     out << FlashTagHeader(28,2);
  149.     WRITE_UWORD(data.depth);
  150.     return out;
  151. }
  152. std::istream& operator>>(std::istream& in, FlashTagRemoveObject2 &data)
  153. {
  154.     READ_UWORD(data.depth);
  155.     return in;
  156. }
  157. DEFINE_SIMPLE_TAG(FlashTagShowFrame,0x01)
  158.