home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Extra 1996 #3 / AmigaPlus_CD-ROM-EXTRA_Nr.3.bin / aminet-spiele / brettspiele / migamind / gads.c < prev    next >
C/C++ Source or Header  |  1990-08-11  |  3KB  |  147 lines

  1. /*****************************************************************************
  2.  
  3.                 GADS.c
  4.  
  5.             Some GFX/INTUI-like-functions.         1-5-90
  6.                                  Ekke
  7. *****************************************************************************/
  8.  
  9.  
  10. #include <exec/types.h>
  11. #include <graphics/gfx.h>
  12. #include <graphics/gfxmacros.h>
  13. #include <proto/all.h>
  14. #include "Gads.h"
  15. #include "MM_Proto.h"
  16.  
  17.  
  18. /***************************************************************************/
  19. void BaseGad(struct RastPort *rp,BGAD *bg)
  20. {
  21.     SetAPen(rp, bg->bg_BPen);
  22.     RectFill(rp, bg->bg_x, bg->bg_y, bg->bg_x+bg->bg_w, bg->bg_y+bg->bg_h);
  23.     SetAPen(rp, bg->bg_TPen);
  24.     Move(rp,bg->bg_x+TEXTPOS_X,bg->bg_y+TEXTPOS_Y);
  25.     Text(rp,bg->bg_text,bg->bg_tsize);
  26. }
  27. /***************************************************************************/
  28. void DrawSysGad(struct RastPort *rp,int id,int selected,int ready)
  29. {
  30. BGAD bg;
  31.  
  32.     if (id == QUIT)
  33.     {   bg.bg_x = 8;
  34.         bg.bg_text = "QUIT";
  35.         bg.bg_TPen = 3;
  36.     }
  37.     else if (id == SHOW)
  38.     {   bg.bg_x = 54;
  39.         if (ready) 
  40.         {    bg.bg_text = "MORE";
  41.         }
  42.         else 
  43.         {    bg.bg_text = "SHOW";
  44.         }
  45.         bg.bg_TPen = TPEN;
  46.     }
  47.  
  48.     bg.bg_w = SYSGAD_W;
  49.     bg.bg_h = SYSGAD_H;
  50.     bg.bg_y = 140;
  51.     bg.bg_tsize = 4;
  52.  
  53.     if (selected)
  54.     {   bg.bg_TPen = TPEN_S;
  55.         bg.bg_BPen = BPEN_S;
  56.     }
  57.     else
  58.     {   bg.bg_BPen = BPEN;
  59.     }
  60.     BaseGad(rp,&bg);
  61. }
  62. /***************************************************************************/
  63. WORD GadPosX(int turn,int id)
  64. {
  65. WORD y;
  66.  
  67.     y = turn ? 22+id*14 : 8+id*14;
  68.     return(y);
  69. }
  70. /***************************************************************************/
  71. WORD GadPosY(int turn)
  72. {
  73. WORD y;
  74.     y = turn ? turn*12+6 : 4;
  75.     return(y);
  76. }
  77. /***************************************************************************/
  78. void DrawGad(struct RastPort *rp,int turn,int id,int value,int selected)
  79. {
  80. BGAD bg;
  81. char v = value + 'A' ;
  82.  
  83.     bg.bg_x = GadPosX(turn,id);
  84.     bg.bg_y = GadPosY(turn);
  85.     bg.bg_w = GAD_W;
  86.     bg.bg_h = GAD_H;
  87.     bg.bg_text = &v;
  88.     bg.bg_tsize = 1;
  89.     if (selected)
  90.     {   bg.bg_TPen = TPEN_S;
  91.         bg.bg_BPen = BPEN_S;
  92.     }
  93.     else
  94.     {   bg.bg_TPen = TPEN;
  95.         bg.bg_BPen = BPEN;
  96.     }
  97.     BaseGad(rp,&bg);
  98. }
  99. /***************************************************************************/
  100. int GetSysID(WORD x,WORD y)
  101. {
  102.     if (y >= 140 && y <= 148)
  103.     {   if (x >=  9 && x <= 42) return(QUIT);
  104.         if (x >= 55 && x <= 88) return(SHOW);
  105.     }
  106.     return(-1);
  107. }
  108. /***************************************************************************/
  109. int GetGadTurn(WORD y)
  110. {
  111. int i;
  112. WORD pos;
  113.  
  114.     if (y >= 4 && y < 4+GAD_H) return(0);
  115.     for (i=1; i<11; i++)
  116.     {   pos = 6+i*12 ;
  117.         if (y >= pos && y < pos+GAD_H) return(i);
  118.     }
  119.     return(-1);
  120. }
  121. /***************************************************************************/
  122. int GetGadID(int turn,WORD x)
  123. {
  124. int i;
  125. WORD pos;
  126.     
  127.     if (turn) 
  128.     {   for (i=0; i<4; i++)
  129.         {    pos = 22+i*14;
  130.         if (x >= pos && x < pos+GAD_W) return(i);
  131.         }
  132.         return(-1);
  133.     }
  134.     for (i=0; i<6; i++)
  135.     {   pos = 8+i*14;
  136.         if (x >= pos && x < pos+GAD_W) return(i);
  137.     }
  138.     return(-1);
  139. }                                            
  140. /***************************************************************************/
  141. int GadNr(int turn,int id)
  142. {
  143.     if (turn) return(2+turn*4+id);
  144.     return(id);
  145. }
  146.  
  147.