home *** CD-ROM | disk | FTP | other *** search
/ WarCraft 2000 - Nuclear Epidemic / W2000.nrg / SOURCE.War2000 / mouse.cpp < prev    next >
C/C++ Source or Header  |  1998-07-08  |  3KB  |  151 lines

  1. #include "ddini.h"
  2. #include "ResFile.h"
  3. #include "FastDraw.h"
  4. #include "mgraph.h"
  5. #include "mode.h"
  6. #define MaxMX 32
  7. #define MsizeX 28
  8. extern int SCRSizeX;
  9. extern int SCRSizeY;
  10. extern int RSCRSizeX;
  11. extern int RSCRSizeY;
  12. extern int COPYSizeX;
  13. typedef byte arr[MaxMX][MaxMX];
  14. RLCTable mptr;
  15. bool realLpressed;
  16. bool realRpressed;
  17. int curptr;
  18. int mouseX;
  19. int mouseX1;
  20. int mouseX2;
  21. int    mouseY;
  22. int mouseY1;
  23. int    mouseY2;
  24. bool Lpressed;
  25. bool Rpressed;
  26. bool MouseOn;
  27. bool Transferred;
  28. int mouseX1a;
  29. int mouseY1a;
  30. arr buf1a;
  31. arr buf2a;
  32. bool Transferreda;
  33. arr buf1;
  34. arr buf2;
  35. int curdx;
  36. int curdy;
  37. void LoadPointer(LPCSTR s){
  38.     LoadRLC(s,&mptr);
  39.     curptr=0;
  40.     mouseX=0;
  41.     mouseY=0;
  42.     mouseX1=0;
  43.     mouseY1=0;
  44.     memset(buf1,0,sizeof buf1);
  45.     memset(buf2,0,sizeof buf2);
  46.     MouseOn=false;
  47.     Transferred=true;
  48.     curdx=0;
  49.     curdy=0;
  50. };
  51. void SetMPtr(int x,int y,int key){
  52.     if(x>RSCRSizeX-1)x=RSCRSizeX-1;
  53.     if ((x!=mouseX)|(y!=mouseY)){
  54.         mouseX=x;
  55.         mouseY=y;
  56.         Transferred=false;
  57.         Transferreda=false;
  58.         realLpressed=key&MK_LBUTTON;
  59.         realRpressed=key&MK_RBUTTON;
  60.     };
  61. };
  62. void ShowMPtra();
  63. void ShowMPtr(){
  64.     //return;
  65.     int i;
  66.     int j;
  67.     //void* Sp1=ScreenPtr;
  68.     //ScreenPtr=RealScreenPtr;
  69.     char* xx=(char*)(ScreenPtr);
  70.     byte b;
  71.     
  72.     //if(!Transferred){
  73.     for(i=0;i<MaxMX;i++)for(j=0;j<MaxMX;j++){
  74.         int xt1=mouseX1+i;
  75.         int yt1=mouseY1+j;
  76.         if(xt1>=0&&xt1<RSCRSizeX&&yt1>=0&&yt1<RSCRSizeY){
  77.             int of=(i+mouseX1)+(j+mouseY1)*SCRSizeX;
  78.             b=xx[of];
  79.             if(b==buf2[i][j])xx[of]=buf1[i][j];
  80.         };
  81.     }
  82.     //};
  83.     mouseX2=mouseX-curdx;
  84.     mouseY2=mouseY-curdy;
  85.     mouseX1=mouseX2;
  86.     mouseY1=mouseY2;
  87.     Transferred=true;
  88.     for(i=0;i<MaxMX;i++)for(j=0;j<MaxMX;j++){
  89.         int xt1=mouseX1+i;
  90.         int yt1=mouseY1+j;
  91.         if(xt1>=0&&xt1<RSCRSizeX&&yt1>=0&&yt1<RSCRSizeY)
  92.             buf1[i][j]=xx[xt1+yt1*SCRSizeX];
  93.     };
  94.     ShowRLCItem(mouseX2,mouseY2,&mptr,curptr,0);
  95.     for(i=0;i<MaxMX;i++)for(j=0;j<MaxMX;j++){
  96.         int xt1=mouseX1+i;
  97.         int yt1=mouseY1+j;
  98.         if(xt1>=0&&xt1<RSCRSizeX&&yt1>=0&&yt1<RSCRSizeY)
  99.             buf2[i][j]=xx[xt1+yt1*SCRSizeX];
  100.     };
  101.     //ScreenPtr=Sp1;
  102.     ShowMPtra();
  103. };
  104. void ShowMPtra(){
  105.     if(DDDebug)return;
  106.     int i;
  107.     int j;
  108.     if(!int(RealScreenPtr))return; 
  109.     bool Rpnt=0;
  110.     char* xx=(char*)(RealScreenPtr);
  111.     byte b;
  112.     
  113.     if(mouseX!=mouseX1a||mouseY!=mouseY1a)Rpnt=true;
  114.     if(Rpnt){
  115.         for(i=0;i<MaxMX;i++)for(j=0;j<MaxMX;j++){
  116.             int xt1=mouseX1a+i;
  117.             int yt1=mouseY1a+j;
  118.             if(xt1>=0&&xt1<RSCRSizeX&&yt1>=0&&yt1<RSCRSizeY){
  119.                 int of=xt1+yt1*RSCRSizeX;
  120.                 b=xx[of];
  121.                 if(b==buf2a[i][j])
  122.                     xx[of]=buf1a[i][j];
  123.             };
  124.         }
  125.     };
  126.     mouseX1a=mouseX2;
  127.     mouseY1a=mouseY2;
  128.     Transferreda=true;
  129.     if(Rpnt){
  130.         for(i=0;i<MaxMX;i++)for(j=0;j<MaxMX;j++){
  131.             int xt1=mouseX1+i;
  132.             int yt1=mouseY1+j;
  133.             if(xt1>=0&&xt1<RSCRSizeX&&yt1>=0&&yt1<RSCRSizeY)
  134.                 buf1a[i][j]=xx[xt1+yt1*RSCRSizeX];
  135.         };
  136.     };
  137.     void* z=ScreenPtr;
  138.     ScreenPtr=RealScreenPtr;
  139.     int SSX=ScrWidth;
  140.     ScrWidth=RSCRSizeX;
  141.     ShowRLCItem(mouseX2,mouseY2,&mptr,curptr,0);
  142.     ScrWidth=SSX;
  143.     ScreenPtr=z;
  144.     for(i=0;i<MaxMX;i++)for(j=0;j<MaxMX;j++){
  145.         int xt1=mouseX1+i;
  146.         int yt1=mouseY1+j;
  147.         if(xt1>=0&&xt1<RSCRSizeX&&yt1>=0&&yt1<RSCRSizeY)
  148.             buf2a[i][j]=xx[xt1+yt1*RSCRSizeX];
  149.     };
  150. };
  151.