?? gui.c
字號:
#include <graphics.h>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
void advlogo(void)
{
static FILE *stream;
signed int cnt;
char filename[30]="logo.bmp";
unsigned char pbuf[256];
unsigned long picsize;
unsigned long info_start;
unsigned int ix,iy,fx,fy;
unsigned char cbyte,colour;
unsigned int cx,cy;
unsigned int ht=154;
float scale=1;
int handle;
unsigned long songlength;
cy=400;
cx=320;
handle = open(filename, O_RDONLY);
songlength=filelength(handle);
close(handle);
if(songlength==99638)
{
stream = fopen(filename,"rb");
cnt=0;
do
{
getc(stream);
cnt++;
}
while(cnt<1078);
cnt=0;
do
{
getc(stream);
cnt++;
}
while(cnt<6400);
iy=cy+ht/2;
fy=cy-ht/2;
do
{
ix=0;
do
{
cbyte=getc(stream);
if(cbyte==0) {colour=BLUE;}
if(cbyte!=0) {colour=LIGHTBLUE;}
if( ((ix>20) && (ix<620)) && ((iy>340) && (iy<472)) )
{
putpixel((ix/scale),(iy/scale),colour);
}
ix++;
}
while(ix<640);
iy--;
}
while(iy>fy);
fclose(stream);
}
}
void c_box(unsigned int wait_time,unsigned int ccolor)
{
unsigned int cx,cy;
cx=320;
cy=240;
setcolor(ccolor);
do
{
rectangle(320-cx,240-cy,320+cx,240+cy);
if(cx>0) {cx--;}
if(cy>0) {cy--;}
}
while((cx>0)||(cy>0));
setcolor(YELLOW);
}
void e_box(unsigned int center_x, unsigned int center_y, unsigned int length, unsigned int height)
{
unsigned int left, right;
unsigned int top, bottom;
unsigned int cx,cy;
cx=0;
cy=0;
do
{
setcolor(WHITE);
rectangle(center_x-cx,center_y-cy,center_x+cx,center_y+cy);
setcolor(DARKGRAY);
rectangle(center_x-cx+1,center_y-cy+1,center_x+cx-1,center_y+cy-1);
setcolor(WHITE);
rectangle(center_x-cx+2,center_y-cy+2,center_x+cx-2,center_y+cy-2);
setcolor(BLUE);
rectangle(center_x-cx+3,center_y-cy+3,center_x+cx-3,center_y+cy-3);
if(cx<length/2) {cx++;}
if(cy<height/2) {cy++;}
}
while((cx<length/2)||(cy<height/2));
setcolor(YELLOW);
}
void gui(void)
{
int gdriver = DETECT, gmode, errorcode;
initgraph(&gdriver, &gmode, "");
/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* return with error code */
}
settextstyle(SMALL_FONT, HORIZ_DIR, 1);
setcolor(YELLOW);
setbkcolor(BLUE);
}
void fubar(unsigned char mode, unsigned int cur, unsigned int max)
{
unsigned int cnt;
unsigned int initx=320,inity=456;
unsigned int length=580,height=16;
unsigned int border=10;
if(mode==1)
{
e_box(initx,inity,length+border,height+border);
}
cnt=((float)cur/(float)max)*length;
line(initx-length/2+cnt,inity-height/2,initx-length/2+cnt,inity+height/2);
}
void close_gui(void)
{
closegraph();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -