home *** CD-ROM | disk | FTP | other *** search
- char temp[1024];
-
- void insertnewbrush(void)
- {
- brush[numbrushes].x=-50;
- brush[numbrushes].y=-50;
- brush[numbrushes].z=-50;
- brush[numbrushes].xl=50;
- brush[numbrushes].yl=50;
- brush[numbrushes].zl=50;
- strcpy(&brush[numbrushes].texture,&defaulttex);
- curbrush=numbrushes;
- numbrushes++;
- }
-
- void drawbrushes(void)
- {
- unsigned char b;
- int vx,vy,vz,vxl,vyl,vzl;
-
- cleardevice();
- for (b=0;b<numbrushes;b++) {
-
- setcolor(7);
- if (b==curbrush) setcolor(12);
- if (curview==0) if (zoommode==1) rectangle(brush[b].x+xdiv,brush[b].y+ydiv,brush[b].xl+xdiv,brush[b].yl+ydiv);
- else rectangle((brush[b].x / zoommode)+xdiv,(brush[b].y / zoommode)+ydiv,(brush[b].xl / zoommode)+xdiv,(brush[b].yl / zoommode)+ydiv);
-
- if (curview==1) if (zoommode==1) rectangle(brush[b].y+xdiv,(brush[b].z*-1)+ydiv,brush[b].yl+xdiv,(brush[b].zl*-1)+ydiv);
- else rectangle((brush[b].y / zoommode)+xdiv,((brush[b].z / zoommode)*-1)+ydiv,(brush[b].yl / zoommode)+xdiv,((brush[b].zl / zoommode)*-1)+ydiv);
-
- if (curview==2) if (zoommode==1) rectangle(brush[b].x+xdiv,(brush[b].z*-1)+ydiv,brush[b].xl+xdiv,(brush[b].zl*-1)+ydiv);
- else rectangle((brush[b].x / zoommode)+xdiv,((brush[b].z / zoommode)*-1)+ydiv,(brush[b].xl / zoommode)+xdiv,((brush[b].zl / zoommode)*-1)+ydiv);
-
- setcolor(12);
- if (curview==0) if (zoommode==1) rectangle(brush[curbrush].x+xdiv,brush[curbrush].y+ydiv,brush[curbrush].xl+xdiv,brush[curbrush].yl+ydiv);
- else rectangle((brush[curbrush].x / zoommode)+xdiv,(brush[curbrush].y / zoommode)+ydiv,(brush[curbrush].xl / zoommode)+xdiv,(brush[curbrush].yl / zoommode)+ydiv);
-
- if (curview==1) if (zoommode==1) rectangle(brush[curbrush].y+xdiv,(brush[curbrush].z*-1)+ydiv,brush[curbrush].yl+xdiv,(brush[curbrush].zl*-1)+ydiv);
- else rectangle((brush[curbrush].y / zoommode)+xdiv,((brush[curbrush].z / zoommode)*-1)+ydiv,(brush[curbrush].yl / zoommode)+xdiv,((brush[curbrush].zl / zoommode)*-1)+ydiv);
-
- if (curview==2) if (zoommode==1) rectangle(brush[curbrush].x+xdiv,(brush[curbrush].z*-1)+ydiv,brush[curbrush].xl+xdiv,(brush[curbrush].zl*-1)+ydiv);
- else rectangle((brush[curbrush].x / zoommode)+xdiv,((brush[curbrush].z / zoommode)*-1)+ydiv,(brush[curbrush].xl / zoommode)+xdiv,((brush[curbrush].zl / zoommode)*-1)+ydiv);
-
- setcolor(8);
- line(0,470,0,479); line(0,479,10,479);
-
- if (curview==0) {
- outtextxy(0,459,"x");
- outtextxy(10,469,"y");
- }
-
- if (curview==1) {
- outtextxy(0,459,"y");
- outtextxy(10,469,"z");
- }
-
- if (curview==2) {
- outtextxy(0,459,"x");
- outtextxy(10,469,"z");
- }
- }
-
-
- strcpy(&workstr,"zm: ");
- strcat(&workstr,itoa(zoommode,temp,10));
- outtextxy(30,469,workstr);
-
- strcpy(&workstr,itoa((brush[curbrush].x-brush[curbrush].xl)*-1,temp,10));
- strcat(&workstr," ");
- strcat(&workstr,itoa((brush[curbrush].y-brush[curbrush].yl)*-1,temp,10));
- strcat(&workstr," ");
- strcat(&workstr,itoa((brush[curbrush].z-brush[curbrush].zl)*-1,temp,10));
- strcat(&workstr," ");
- strcat(&workstr,brush[curbrush].texture);
-
- outtextxy(80,469,workstr);
-
- if (movemode==1) outtextxy(20,459,"M");
- putpixel(0+xdiv,0+ydiv,15);
- }
-
- void getnewdefaulttexture()
- {
- outtextxy(0,40,"Enter default texture for new inserted brushes: ");
- gotoxy(1,1);
- gets(defaulttex);
- if (numbrushes>0) drawbrushes(); else cleardevice();
- }
-
- /* this is VERY buggy, i think (not sure) */
- void deletecurbrush(void)
- {
- unsigned char i;
-
- if (numbrushes>1) {
- for (i=curbrush;i<numbrushes-2;i++) brush[i]=brush[i+1];
- numbrushes--;
- if (curbrush>=numbrushes) curbrush=0;
- }
- else outtextxy(0,0,"gotta have at least one brush...");
- }
-
-
-
- void getnewmoverate(void)
- {
- outtextxy(0,40,"Enter new moverate: ");
- gotoxy(1,1);
- gets(temp);
- moverate = atoi(temp);
- if (numbrushes>0) drawbrushes();
- else cleardevice();
- }
-
- void save(void)
- {
- FILE *f;
- FILE *e;
- cube_t c;
- ent_t en;
- char saveas[20];
- char fstring[20];
- unsigned char i;
-
- if (numbrushes>0) {
- outtextxy(0,40,"Do not give an extension! save as: ");
- gotoxy(0,0);
- gets(saveas);
- strcpy(&fstring,&saveas);
- strcat(&fstring,".qck");
- f = fopen(fstring,"wb");
- for (i=0;i<numbrushes;i++) {
- c = brush[i];
- strcpy(&temp,&c.texture);
- c.texture[0] = strlen(&temp);
- strcpy(&c.texture[1],&temp);
- fwrite(&c, sizeof(c), 1, f);
- }
- fclose(f);
-
- strcpy(&fstring,&saveas);
- strcat(&fstring,".ent");
- e = fopen(fstring,"wb");
- for (i=0;i<numentities;i++) {
- en = entity[i];
- strcpy(&temp,&en.class);
- en.class[0] = strlen(&temp);
- strcpy(&en.class[1],&temp);
- fwrite(&en, sizeof(en), 1, e);
- }
- fclose(e);
- drawbrushes();
- outtextxy(0,0,"Saved...");
- }
- else outtextxy(0,0,"nothing to save.");
- }
-
- void insertnewentity(void)
- {
-
- strcpy(&entity[numentities].class,"info_player_start");
- entity[numentities].ox=0;
- entity[numentities].oy=0;
- entity[numentities].oz=0;
- entity[numentities].angle=0;
- curentity=numentities;
- numentities++;
- }
-
- void load(void)
- {
- FILE *f;
- FILE *e;
- char saveas[20];
- char fstring[20];
- unsigned char i;
- char l[256];
- cube_t c;
- ent_t en;
-
- outtextxy(0,40,"load brush and entity data (use shift-l for brushes only): ");
- gotoxy(0,0);
- gets(l);
- if (l=="") goto alldone;
- strcpy(&fstring,&l);
- strcat(&fstring,".qck");
- f = fopen(fstring,"rb");
- numbrushes=0;
- do {
- if (fread(&c, sizeof(c), 1, f)==1) {
- insertnewbrush();
- brush[numbrushes-1]=c;
- strcpy(&temp,c.texture);
- temp[c.texture[0]+1]=0;
- strcpy(&brush[numbrushes-1].texture[0],&temp[1]);
- }
- } while (!feof(f));
- fclose(f);
-
- strcpy(&fstring,&l);
- strcat(&fstring,".ent");
- e = fopen(fstring,"rb");
- numentities=0;
- do {
- if (fread(&en, sizeof(en), 1, e)==1) {
- insertnewentity();
- entity[numentities-1]=en;
- strcpy(&temp,en.class);
- temp[en.class[0]+1]=0;
- strcpy(&entity[numentities-1].class[0],&temp[1]);
- }
- } while (!feof(e));
- fclose(e);
- alldone:
- }
-
- void oldload(void)
- {
- FILE *f;
- char l[20];
- char fstring[256];
- unsigned char i;
- cube_t c;
-
- outtextxy(0,40,"brushes only load: ");
- gotoxy(0,0);
- gets(l);
- if (l=="") goto alldone;
-
- strcpy(&fstring,&l);
- f = fopen(fstring,"rb");
- numbrushes=0;
- do {
- if (fread(&c, sizeof(c), 1, f)==1) {
- insertnewbrush();
- brush[numbrushes-1]=c;
- strcpy(&temp,c.texture);
- temp[c.texture[0]+1]=0;
- strcpy(&brush[numbrushes-1].texture[0],&temp[1]);
- }
- } while (!feof(f));
- fclose(f);
-
- itoa(numbrushes,l,10);
- strcpy(&workstr,"Loaded ");
- strcat(&workstr,&l);
- strcat(&workstr," brushes");
- curview=0;
- drawbrushes();
- outtextxy(0,0,workstr);
- alldone:
- }
-
-
- void texture(void)
- {
- char t[256];
-
- if (numbrushes>0) {
- outtextxy(0,40,"New texture for this brush: ");
- gotoxy(0,0);
- gets(t);
- strcpy(&brush[curbrush].texture,&t);
- }
- }
-
-
- void drawentities(void)
- {
- unsigned char e;
- unsigned char r;
-
- r=2;
- setcolor(7);
- if (numentities>0) {
- for (e=0;e<numentities;e++) {
- if (curview==0) circle((entity[e].ox / zoommode)+xdiv,(entity[e].oy / zoommode)+ydiv,r);
- if (curview==1) circle((entity[e].oy / zoommode)+xdiv,((entity[e].oz / zoommode)*-1)+ydiv,r);
- if (curview==2) circle((entity[e].ox / zoommode)+xdiv,((entity[e].oz / zoommode)*-1)+ydiv,r);
- }
-
- setcolor(12);
-
- if (curview==0) circle((entity[curentity].ox / zoommode)+xdiv,(entity[curentity].oy / zoommode)+ydiv,r);
- if (curview==1) circle((entity[curentity].oy / zoommode)+xdiv,((entity[curentity].oz / zoommode)*-1)+ydiv,r);
- if (curview==2) circle((entity[curentity].ox / zoommode)+xdiv,((entity[curentity].oz / zoommode)*-1)+ydiv,r);
-
- strcpy(&workstr,"Angle: ");
- strcat(&workstr,itoa(entity[curentity].angle,temp,10));
- outtextxy(400,459,workstr);
- strcpy(&workstr,"Class: ");
- strcat(&workstr,entity[curentity].class);
- outtextxy(400,469,workstr);
-
- }
- }
-
- void curentityangle(void)
- {
- char s[256];
- int i;
-
- if (numentities>0) {
- outtextxy(0,40,"New angle for this entity: ");
- gotoxy(0,0);
- gets(s);
- if (s=="") i=0;
- else i = atoi(s);
- entity[curentity].angle=i;
- }
- drawbrushes();
- drawentities();
- }
-
- void curentityclass(void)
- {
- char s[256];
-
- if (numentities>0) {
- outtextxy(0,40,"New classname for this entity: ");
- gotoxy(0,0);
- gets(s);
- if (s=="") strcpy(&s,"info_player_start");
- else strcpy(&entity[curentity].class,&s);
- }
- drawbrushes();
- drawentities();
- }
-
-