home *** CD-ROM | disk | FTP | other *** search
/ Quake++ for Quake / Quake++.iso / quake / edquake / code / wadmap.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-06  |  4.0 KB  |  156 lines

  1. //external map/wad functions
  2. #include "bsp.h"
  3. #include "disk.h"
  4. #include "pak.h"
  5. #include "input.h"
  6. #include "svgacc.h"
  7. #include "grfx.h"
  8. //temp
  9. #include <stdio.h>
  10. //end temp
  11.  
  12. void breakbox(int x0, int y0, int x1, int y1)
  13. {
  14.    drwbox(SET,WHITE,x0+1,y0+1,x1-1,y1-1);
  15.    drwbox(SET,BLACK,x0,y0,x1,y1);
  16. }
  17.  
  18. void screentextures()
  19. {
  20.    drwfillbox(SET,LTGRAY,0,0,800,600);
  21.    inputbox(0,20,200,312,"Selected Textures");
  22.    drwfillbox(SET,BLACK,5,40,195,308);
  23.    drwfillbox(SET,BLUE,205,45,295,74);
  24.    drwstring(SET,YELLOW,BLUE,"Texture",222,46);
  25.    drwstring(SET,YELLOW,BLUE,"Commands",217,60);
  26.    breakbox(205,45,295,74);
  27.    breakbox(205,75,295,179);
  28.    button(210, 80,290, 95,"  Delete");
  29.    button(210,100,290,115,"  Import");
  30.    button(210,120,290,135,"  Export");
  31.    button(210,140,290,155," Make WAD");
  32.    button(210,160,290,175,"   Exit");
  33.    drwfillbox(SET,BLUE,0,0,800,15);
  34.    drwstring(SET,WHITE,BLUE,"EdQuake v0.02    (c) copyright 1996 Scott Mitting/David Langeliers  ",25,1);
  35.    scrollbutton(184,280,"");
  36.    scrollbutton(184,294,"");
  37.    impress(40,460,477,573);
  38.    pcxput(SET,40,460,"logo.pcx");
  39.    mouseshow();
  40. }
  41.  
  42. void showmip(int e)
  43. {
  44.    int cx, cy;
  45.    fseek(pak.p,texture[e].pakoffset,0);
  46.    drwfillbox(SET,LTGRAY,298,18,600,276);
  47.    impress(299,19,301+texture[e].width,21+texture[e].height);
  48.    for (cy = 0; cy < texture[e].height; cy++)
  49.      for (cx = 0; cx < texture[e].width; cx++)
  50.     drwpoint(SET,fgetc(pak.p),cx+300,cy+20);
  51. }
  52.  
  53. void showmenutexture(int showE, int curE)
  54. {
  55.    int t,qt;
  56.    char buf[80];
  57.    qt = 40;
  58.    mousehide();
  59.    for (t = 1; t < 20; t++)
  60.    {
  61.      if (t != curE)
  62.      {
  63.     drwfillbox(SET, BLACK,6,qt,183,qt+14);
  64.     sprintf(buf, "%s", texture[t+showE].name);
  65.     drwstring(SET, WHITE,BLACK,buf,11,qt);
  66.      }
  67.      else
  68.      {
  69.     drwfillbox(SET,RED,6,qt,183,qt+14);
  70.     sprintf(buf, "%s", texture[t+showE].name);
  71.     drwstring(SET, YELLOW,RED,buf,11,qt);
  72.      }
  73.      qt+=14;
  74.    }
  75.    mouseshow();
  76. }
  77.  
  78. //takes all textures and throws them into a wad
  79. void mip2wad()
  80. {
  81.    char *p;
  82.    FILE *out;
  83.    long t;
  84.    long mipoffset[256];
  85.    long mipsize[256];
  86.    p = wgetstringbox("Create WAD2", "Save as:", "texture.wad");
  87.    out = fopen(p,"wb");
  88.    if (!out) return;
  89.    fwrite("WAD2",4,1,out);
  90.    t = numtex;
  91.    fwrite(&t,4,1,out);
  92.    t = 0;
  93.    fwrite(&t,4,1,out);
  94.    fclose(out);
  95. }
  96.  
  97. void selecttextures()
  98. {
  99.    //buttons
  100.    button_t delbut, impbut, expbut, exibut, wadbut;
  101.    button_t up, down;
  102.    int showE = 0, curE = 1;
  103.    int i, k, mbuts, mx, my;
  104.    //setupscreen
  105.     up = scrollbutton(184,280,"");
  106.     down = scrollbutton(184,294,"");
  107.    screentextures();
  108.    delbut = button(210, 80,290, 95,"  Delete");
  109.    impbut = button(210,100,290,115,"  Import");
  110.    expbut = button(210,120,290,135,"  Export");
  111.    wadbut = button(210,140,290,155," Make WAD");
  112.    exibut = button(210,160,290,175,"   Exit");
  113.    while (k != 27)
  114.    {
  115.      showmenutexture(showE, curE);
  116.      scrollbar(184,40,279,showE+curE,numtex);
  117.      showmip(showE+curE);
  118.         while (!kbhit() && !mbuts)
  119.         {
  120.            mousestatus(&mx,&my,&mbuts);
  121.            if (mbuts & 1)//scroll
  122.            {
  123.           if (hitbutton(mx,my,up)) curE-=1;
  124.           if (hitbutton(mx,my,down)) curE+=1;
  125.           if (hitbutton(mx,my,exibut)) return;
  126.           if (hitbutton(mx,my,wadbut)) mip2wad();
  127.           //select
  128.           if (mx < 184 && my < 300 && my > 40)
  129.              curE =  ((my - 40) / 14)+1;
  130.            }
  131.            if (mbuts & 2)//scroll fast
  132.            {
  133.           if (hitbutton(mx,my,up)) showE-=3;
  134.           if (hitbutton(mx,my,down)) showE+=3;
  135.            }
  136.         }
  137.         if (!mbuts) k = getkey();
  138.         mbuts = 0;
  139.  
  140.      if (k == a_DOWN) curE++;
  141.      if (k == a_UP)   curE--;
  142.      if (k == a_PGDN) showE+=15;
  143.      if (k == a_PGUP) showE-=15;
  144.      if (k == a_HOME) curE=1;
  145.      if (k == a_END)  curE=19;
  146.      if (k == a_ESC)   return;
  147.      if (curE > 19) {showE++;curE=19;}
  148.      if (curE < 1)  {showE--;curE=1;}
  149.      if (showE < 0) {showE = 0; curE = 1;}
  150.      if (showE + 20 > numtex) {showE = numtex - 20; curE=19;}
  151.    }
  152. }
  153.  
  154.  
  155.  
  156.