Exemplo n.º 1
0
void NoteCanvas::read_internal(char *& st)
{
    const char * p = st;
    QTextCodec* codec = QTextCodec::codecForLocale();
    QTextStream stream(p);
    stream.setCodec(codec);
    QByteArray ba;
    stream   >> ba;
    QString temp = QString::fromLocal8Bit(ba);
    char* test = read_string(st);
    Q_UNUSED(test);
    note = temp;


    char * k = read_keyword(st);
    read_color(st, "color", itscolor, k);
    read_font(st, "font", itsfont, k);
    read_color(st, "fg", fg_c, k);

    if (strcmp(k, "xyzwh"))
        wrong_keyword(k, "xyzwh");

    read_xyzwh(st, this);
    width_scale100 = width();
    height_scale100 = height();
    set_center100();
    show();
}
Exemplo n.º 2
0
void insert_ttfont(const char *filename, TTStreamWriter& stream,
                   font_type_enum target_type, std::vector<int>& glyph_ids)
{
    struct TTFONT font;

    read_font(filename, target_type, glyph_ids, font);

    /* Write the header for the PostScript font. */
    ttfont_header(stream, &font);

    /* Define the encoding. */
    ttfont_encoding(stream, &font, glyph_ids, target_type);

    /* Insert FontInfo dictionary. */
    ttfont_FontInfo(stream, &font);

    /* If we are generating a type 42 font, */
    /* emmit the sfnts array. */
    if (font.target_type == PS_TYPE_42 ||
        font.target_type == PS_TYPE_42_3_HYBRID)
    {
        ttfont_sfnts(stream, &font);
    }

    /* Emmit the CharStrings array. */
    ttfont_CharStrings(stream, &font, glyph_ids);

    /* Send the font trailer. */
    ttfont_trailer(stream, &font);

} /* end of insert_ttfont() */
Exemplo n.º 3
0
void get_pdf_charprocs(const char *filename, std::vector<int>& glyph_ids, TTDictionaryCallback& dict) {
    struct TTFONT font;

    read_font(filename, PDF_TYPE_3, glyph_ids, font);

    for (std::vector<int>::const_iterator i = glyph_ids.begin();
         i != glyph_ids.end(); ++i) {
        StringStreamWriter writer;
        tt_type3_charproc(writer, &font, *i);
        const char* name = ttfont_CharStrings_getname(&font, *i);
        dict.add_pair(name, writer.str().c_str());
    }
}
Exemplo n.º 4
0
void NoteCanvas::read_internal(char * & st) {
  note = toUnicode(read_string(st));
  
  char * k = read_keyword(st);
  read_color(st, "color", itscolor, k);
  read_font(st, "font", itsfont, k);
  read_color(st, "fg", fg_c, k);
  
  if (strcmp(k, "xyzwh"))
    wrong_keyword(k, "xyzwh");
  
  read_xyzwh(st, this);
  width_scale100 = width();
  height_scale100 = height();
  set_center100();
  show();
}
Exemplo n.º 5
0
int main(void)
{
    initImage();
    initPlace();

    large_font = read_font("font.txt");
    initAudio();
    initAudioNUM();

    int IsEnding = 0;
    showingPlane = START_PLANE;

    while (!IsEnding)
    {
        clearScreen();

        switch (showingPlane)
        {
        case 0:
            start();
            showingPlane = 1;
            break;
        case 1:
            Menu();
            break;
        case 2:
            SinglePlayer();
            break;
        case 3:
            MuitiplePlayers();
            break;
        case 4:
            ShowHelp();
            showingPlane = 1;
            break;
        }

        drawCmdWindow();

    } /* while (IsEnding) */

    return 0;
}
Exemplo n.º 6
0
TextCanvas * TextCanvas::read(char *& st, UmlCanvas * canvas, char * k)
{
    if (!strcmp(k, "textcanvas_ref"))
        return ((TextCanvas *) dict_get(read_id(st), "textcanvas", canvas));
    else if (!strcmp(k, "textcanvas")) {
        int id = read_id(st);
        QString text = read_string(st);
        UmlFont font;
        UmlColor fg_c = UmlBlack;
        UmlColor bg_c = UmlTransparent;

        k = read_keyword(st);
        read_font(st, "font", font, k);
        read_color(st, "fg", fg_c, k);
        read_color(st, "bg", bg_c, k);

        if (strcmp(k, "xyzwh"))
            wrong_keyword(k, "xyzwh");

        int x = (int) read_double(st);

        TextCanvas * result =
                new TextCanvas(canvas, x, (int) read_double(st), id);

        read_zwh(st, result);
        result->width_scale100 = result->width();
        result->height_scale100 = result->height();
        result->set_center100();
        result->text = text;
        result->itsfont = font;
        result->fg_c = fg_c;
        result->bg_c = bg_c;
        result->show();

        return result;
    }
    else
        return 0;
}
Exemplo n.º 7
0
Glyph* read_idraw_graphic (
    FILE* file, const Brush* pb, const Color* pfg, const Color* pbg,
    const Font* pf, Stipple* ps
) {
    skip(file);
    Transformer tx;
    Glyph* glyph = nil;
    const LayoutKit& layout = *LayoutKit::instance();
    if (fscanf(file, "%s", buffer) != EOF) {
        figure& fig = figures[which(figures, buffer)];

        if (strcmp(fig.name, "Idraw") == 0) {
            fscanf(file, "%d", &drawing_version);
            figures = versions[drawing_version];
        }
        const Brush* b = (fig.brush) ? read_brush(file) : nil;
        const Color* fg = (fig.foreground) ? read_color(file) : nil;
        const Color* bg = (fig.background) ? read_color(file) : nil;
        const Font* f = (fig.font) ? read_font(file) : nil;
        Stipple* s = (fig.pattern) ? read_stipple(file) : nil;
        if (fig.transformer) {
            read_transformer(file, tx);
        }

        if (pb) b = pb;
        if (pfg) fg = pfg;
        if (pbg) bg = pbg;
        if (pf) f = pf;
        if (ps) s = ps;

        if (fig.name == nil) {
            ; // error
        } else if (
            strcmp(fig.name, "Idraw") == 0 || strcmp(fig.name, "Pict") == 0
        ) {
            Glyph* pic = layout.overlay();
            Glyph* g;
            do {
                g = read_idraw_graphic(file, b, fg, bg, f, s);
                if (g != nil) {
                    pic->append(g);
                }
            } while (g != nil);
            glyph = pic;
        } else if (strcmp(fig.name, "eop") == 0) {
            glyph = nil;
        } else if (strcmp(fig.name, "Text") == 0) {
            skip(file);
            fscanf(file, "%s", buffer);
            getc(file);
            PolyGlyph* col = layout.vbox_first_aligned();
            PolyGlyph* line = layout.hbox_first_aligned();
	    FontBoundingBox bbox;
	    f->font_bbox(bbox);
            Coord lineheight = bbox.font_ascent() + bbox.font_descent();
            if (_idraw_font_metrics) {
                lineheight /= fixtextscale;
            }
            int c;
            while ((c = getc(file)) != ']') {
                if (c == '\n') {
                    line->append(layout.strut(f));
                    col->append(
			layout.v_fixed_span(line, lineheight)
		    );
                    line = layout.hbox();
                } else if (c == ' ') {
                    if (_idraw_font_metrics) {
                        line->append(
			    layout.shape_of(new Character(' ', f, fg))
			);
                    } else {
                        line->append(new Character(' ', f, fg));
                    }
                } else if (c != ')' && c != '(') {
                    if (c == '\\') {
                        c = getc(file);
			if (isdigit(c)) {
			    c -= '0';
			    c = (c * 8) + getc(file) - '0';
			    c = (c * 8) + getc(file) - '0';
			}
                    }
                    line->append(new Character(c, f, fg));
                }
            }
            Transformer fixtext;
            if (_idraw_font_metrics) {
                fixtext.scale(fixtextscale, fixtextscale);
            }
            fixtext.translate(0, bbox.font_descent() - lineheight);
            glyph = new TransformSetter(col, fixtext);
        } else {
            skip(file);
            int c = fig.coords;
            if (c == -1) { 
                fscanf(file, "%d", &c);
            }
            Coord xx, yy;
            Coord* x = new Coord[c];
            Coord* y = new Coord[c];
            for (int i = 0; i < c; ++i) {
                fscanf(file, "%g %g", &xx, &yy);
                x[i] = xx;
                y[i] = yy;
            }

            const Brush* brush = (b != no_brush) ? b : nil;
            const Color* stroke = fg;
            const Color* fill = (
                (s != no_stipple) ? dither_color(fg, bg, s->_dither) : nil
            );
            if (strcmp(fig.name, "Line") == 0) {
                glyph = new Line(brush, stroke, fill, x[0], y[0], x[1], y[1]);
            } else if (strcmp(fig.name, "BSpl") == 0) {
                glyph = new Open_BSpline(brush, stroke, fill, x, y, c);
            } else if (strcmp(fig.name, "CBSpl") == 0) {
                glyph = new Closed_BSpline(brush, stroke, fill, x, y, c);
            } else if (strcmp(fig.name, "MLine") == 0) {
                glyph = new Polyline(brush, stroke, fill, x, y, c);
            } else if (strcmp(fig.name, "Poly") == 0) {
                glyph = new Polygon(brush, stroke, fill, x, y, c);
            } else if (strcmp(fig.name, "Rect") == 0) {
                glyph = new Rectangle(brush, stroke, fill,x[0],y[0],x[1],y[1]);
            } else if (strcmp(fig.name, "Circ") == 0) {
                fscanf(file, "%f", &xx);
                glyph = new Circle(brush, stroke, fill, x[0], y[0], xx);
            } else if (strcmp(fig.name, "Elli") == 0) {
                fscanf(file, "%f %f", &xx, &yy);
                glyph = new Ellipse(brush, stroke, fill, x[0], y[0], xx, yy);
            } else {
                glyph = nil;
            }
            delete x;
            delete y;
        }
        for (int extra = fig.skip; extra > 0; --extra) {
            skip(file);
        }
    }
    if (glyph != nil && !tx.identity()) {
        glyph = new TransformSetter(glyph, tx);
    }
    return glyph;
}
Exemplo n.º 8
0
int single_game(){
    Audio RRR;
    openAudioFile(".\\wav\\RRR.wav", &RRR);
	initializeKeyInput();
	Character yg = characterMaking1(".\\pic\\yg.pixel",".\\pic\\yg.color");
	int key_val[NUM_KEYS]={VK_A,VK_D,VK_ESCAPE};
	int stand=0,score=0,standBrick,pDown1,pDown2;
	double drop=0,scoreCount=0;
	Brick bricks[15];
	int i,j,k;
    char scoreStr[4]={'0'};
	for(i=0;i<10;i++){
		bricks[i].y=-1;
		bricks[i].w=40;
		bricks[i].h=2;
		if(i%2==0)bricks[i].color=15;
		else if(i<=5)bricks[i].color=8;
		else if(i>5)bricks[i].color=12;
		else bricks[i].color=10;
	}
	bricks[0].x=0;
	bricks[0].y=100;
	Font *large_font=read_font("font.txt");
	float lastbrick=0;
	int hp = 10,second=0;
	float rate=0.15;
	while(1){
		clearScreen();
		srand(clock());
        for(i=0;i<10;i++){
            if(bricks[i].y>0)bricks[i].y--;
            else if(bricks[i].y==0)bricks[i].y=-100;
            for(k=0;k<2;k++){
                for(j=0;j<bricks[k].w;j++){
                    putString(bricks[i].x+j,bricks[i].y+k,"=",bricks[i].color,0);
                }
            }
        }
        if(score>50){
            rate = 0.2;
        }
        else if(score>75){
            rate = 0.25;
        }
        else if(score>100){
            rate = 0.3;
        }
		if((float)clock()/(float)CLOCKS_PER_SEC-(float)lastbrick>rate&&rand()%10==1){
			for(i=0;i<10;i++){
				if(bricks[i].y<0){
					bricks[i].y=170;
					bricks[i].x=rand()%185;
					lastbrick=(float)clock()/(float)CLOCKS_PER_SEC;
					for(k=0;k<2;k++){
                        for(j=0;j<bricks[i].w;j++){
                            putString(bricks[i].x+j,bricks[i].y+k,"=",bricks[i].color,0);
                        }
                    }
					break;
				}
			}
		}

        for(k=0;k<10;k++){
        	if(abs(yg.y+yg.h-bricks[k].y)<=2&&(
            (yg.x+yg.w>bricks[k].x&&yg.x+yg.w<bricks[k].x+bricks[k].w)||
            (yg.x>bricks[k].x&&yg.x<bricks[k].x+bricks[k].w))){
        		stand=1;
        		standBrick=k;
        		yg.y=bricks[k].y-yg.h;
                break;
			}
			else if(k==9){
                stand=0;
                standBrick=-1;
			}
		}

        if(stand==1){
            drop=0;
            second++;
            if(bricks[standBrick].color==15&&second==15){
                second=0;
                if(hp<10)hp++;
            }
            else if(bricks[standBrick].color==12){
                second++;
                if(second==20){
                    second=0;
                    hp--;
                    playAudio(&RRR);
                }
            }
            else if(bricks[standBrick].color==8){
                if(second==10){
                    second=0;
                    bricks[standBrick].y=-100;
                }
            }
		}
		else{
            if(drop<2)drop+=0.5;
            yg.y+=(int)drop;
            second=0;
		}

		if(yg.y<0){
            yg.y+=10;
            drop=3;
            hp-=4;
            playAudio(&RRR);
		}
		for (k = 0 ; k < NUM_KEYS ; k++){
            if(KEY_DOWN(key_val[k])){
                switch (key_val[k]){
	                case VK_A:
	                	if(yg.x>=0)yg.x-=5;
	                	break;
	                case VK_D:
	                	if(yg.x+yg.w<225)yg.x+=5;
	                	break;
                    case VK_ESCAPE:
                        return 3;
                        break;
          	  	}
            }
        }
        show_image(yg.pic,yg.x,yg.y);
        for(i=0;i<225;i++){
            for(j=151;j<=170;j++){
                putString(i,j," ",0,0);
            }
        }
		putStringLarge(large_font,159,158,"HP ",15);
		putStringLarge(large_font,159,152,"STAGE ",15);
		scoreCount++;
		score = (pow(scoreCount/300,1.5));
		scoreStr[0]=score/100+'0';
		scoreStr[1]=score/10%10+'0';
		scoreStr[2]=score%10+'0';
		putStringLarge(large_font,201,152,scoreStr,15);
		for(i=0;i<hp;i++){
            for(j=1;j<5;j++){
                for(k=0;k<=4;k++)putString(180+i*4+j,158+k,"|",12,0);
            }
		}
		for(i=0;i<225;i++)putString(i,0,"V",12,0);
        for(i=0;i<225;i++){
            putString(i,149,"=",12,0);
        }
        for(i=0;i<150;i++){
            putString(0,i,"|",0,12);
            putString(224,i,"|",0,12);
        }
        drawCmdWindow();
        if(yg.y>150||hp<=0){
            break;
		};
        if(KEY_UP(VK_P)&&pDown1)pDown1=0;
        if(KEY_UP(VK_P)&&pDown2)pDown2=0;
        if(KEY_DOWN(VK_P)&&!pDown1){
            pDown1=1;
            putStringLarge(large_font,45,70,"Press P to continue",12);
            drawCmdWindow();
            Sleep(500);
            while(1){
                if(KEY_DOWN(VK_P)&&!pDown2){
                    pDown2=1;
                    break;
                }
            }
        }
		Sleep(20);
	}
	pauseAudio(&RRR);
	Image * jh =read_image(".\\pic\\jh.pixel",".\\pic\\jh.color");
	show_image(jh,15,30);
    putStringLarge(large_font,75,80,"SCORE ",15);
    putStringLarge(large_font,120,80,scoreStr,15);
    drawCmdWindow();
	Audio *barbar;
	openAudioFile(".\\wav\\88wav.wav",&barbar);
	playAudio(&barbar);
	Sleep(3500);
	int flagg = 1;
    putStringLarge(large_font, 45, 90, "Press esc to exit", 15);
    drawCmdWindow();
    while(flagg){
        if(KEY_DOWN(VK_ESCAPE))return 3;
    }
	clearScreen();
}
Exemplo n.º 9
0
void MuitiplePlayers(void)
{
    Font *large_font = read_font("font.txt");
    /* 啟動鍵盤控制 */
    initializeKeyInput();
    char ch,prech='0';
    char *card;
    card = (char*)malloc(sizeof(char));
    *(card+1) = '\0';

    int isWin=0,isLose=0;
    int count = 0, pick;
    int initime =clock(), time;
    int turn=2; // 1:Right 2:Left

    while(isWin<3 && isLose<3)
    {
        clearScreen();
        time = clock() - initime;

        ch = getKeyEventVirtual();
        switch(ch)
        {
        case VK_LEFT: //右方拍桌
            if(( count==pick && time<10 )|| count==14)
            {
                //win(10);
                putStringLarge(large_font, 200, 20, "YOU WIN!!", 15, 15);
                drawCmdWindow();
                Sleep(200);
                turn = 2;
                time = 0;
                isLose++;
            }
            else if(count==pick)
            {//show_image(*(poker+1),0,0);
    //drawCmdWindow();
                //AIwin();
                putStringLarge(large_font, 200, 20, "YOU LOSE! How slow you are!", 15, 15);
                drawCmdWindow();
                Sleep(200);
                turn = 1;
                time = 0;
                isWin++;
            }

            else
            {
                //lose(10);
                putStringLarge(large_font, 200, 20, "YOU LOSE! Watch out the number!", 15, 15);
                drawCmdWindow();
                Sleep(200);
                turn = 1;
                time = 0;
                isWin++;
            }
            break;

            break;
        case 0x58: //左方拍桌
            if(( count==pick && time<10 )|| count==14)
            {
                //win(10);
                putStringLarge(large_font, 10, 20, "YOU WIN!!", 15, 15);
                drawCmdWindow();
                Sleep(200);
                turn = 1;
                time = 0;
                isWin++;
            }
            else if(count==pick)
            {
                //AIwin();
                putStringLarge(large_font, 10, 20, "YOU LOSE! How slow you are!", 15, 15);
                drawCmdWindow();
                Sleep(200);
                turn = 2;
                time = 0;
                isLose++;
            }

            else
            {
                //lose(10);
                putStringLarge(large_font, 10, 20, "YOU LOSE! Watch out the number!", 15, 15);
                drawCmdWindow();//show_image(*(poker+1),0,0);
    //drawCmdWindow();
                Sleep(200);
                turn = 2;
                time = 0;
                isLose++;
            }
            break;

        case 0x5A: //左方發牌
            if(count==pick|| count==14)
            {
                putStringLarge(large_font, 10, 20, "YOU LOSE! Watch out the number!", 15, 15);
                drawCmdWindow();
                Sleep(200);
                turn = 2;
                time = 0;
                isLose++;
            }
            else if(turn == 2)
            {
                count = count%13 +1;
                if(count<11)
                    *card = ('0'+count);
                else if(count == 11)
                    *card = 'J';
                else if(count == 12)
                    *card = 'Q';
                else if(count == 13)
                    *card = 'K';
                putStringLarge(large_font, 100, 40, "NUM   ", 0, 15);
                putStringLarge(large_font, 150, 40, card, 0, 15);
                pick = (rand()%13)+1;
                if(pick<11)
                    *card = ('0'+pick);
                else if(pick == 11)
                    *card = 'J';
                else if(pick == 12)
                    *card = 'Q';
                else if(pick == 13)
                    *card = 'K';
                else if(pick == 14)
                    *card = 'P';
                putStringLarge(large_font, 100, 50, "CARD  ", 0, 15);
                putStringLarge(large_font, 150, 50, card, 0, 15);
                time = 0;
                turn = 1;
                int ran = (rand()%4)+1;
                //show_image(poker[0][0],100,20);
                drawCmdWindow();
            }//show_image(*(poker+1),0,0);
    //drawCmdWindow();
            break;
        case VK_DOWN: //右方發牌
            if(count==pick|| count==14)
            {
                putStringLarge(large_font, 200, 20, "YOU LOSE! Watch out the number!", 15, 15);
                drawCmdWindow();
                Sleep(200);
                turn = 1;
                time = 0;
                isWin++;
            }
            else if(turn == 1)
            {
                count = count%13 +1;
                if(count<11)
                    *card = ('0'+count);
                else if(count == 11)
                    *card = 'J';
                else if(count == 12)
                    *card = 'Q';
                else if(count == 13)
                    *card = 'K';
                putStringLarge(large_font, 100, 40, "NUM   ", 0, 15);
                putStringLarge(large_font, 150, 40, card, 0, 15);
                pick = (rand()%13)+1;
                if(pick<11)
                    *card = ('0'+pick);
                else if(pick == 11)
                    *card = 'J';
                else if(pick == 12)
                    *card = 'Q';
                else if(pick == 13)
                    *card = 'K';
                else if(pick == 14)
                    *card = 'P';
                putStringLarge(large_font, 100, 50, "CARD  ", 0, 15);
                putStringLarge(large_font, 150, 50, card, 0, 15);
                time = 0;
                turn = 2;
                int ran = (rand()%4)+1;
                //show_image(poker[0][0],100,20);
                drawCmdWindow();
            }
            break;//show_image(*(poker+1),0,0);
    //drawCmdWindow();

        case VK_ESCAPE:
            break;
        }

    }
    if(winTimes==3)
    {
        Loser2(50,35);//send location
        Winner2(300,35);//send location
        showingPlane =1;
    }
    else if(loseTimes==3)
    {
        Loser2(300,35);//send location
        Winner2(50,35);//send location
        showingPlane =1;
    }
}
Exemplo n.º 10
0
void menu_init(SDL_Surface *screen)
{
	
	FULL_DISPLAY_X = currprefs.gfx_width_win;
	FULL_DISPLAY_Y = currprefs.gfx_height_win;
	RATIO = 640/FULL_DISPLAY_X;
	char window_image[255];
	
	if (is_inited) return;
	
    strcpy (window_image, "");
	
	if (RATIO == 1) strcat (window_image, WINDOWIMAGE); else strcat (window_image, WINDOWIMAGE_SMALL);
	
	tmp_surface=IMG_Load(window_image);

	if (tmp_surface == NULL) {write_log("Impossible to load window background image\n"); return;}
	image_window=SDL_DisplayFormat(tmp_surface);
	SDL_FreeSurface (tmp_surface);
	
	
	TTF_Init();

	menu_font16 = read_font(FONT_PATH, 16);
	menu_font20 = read_font(FONT_PATH, 20);
	menu_font8 = read_font(FONT_PATH_SMALL, 8);
	menu_font10 = read_font(FONT_PATH_SMALL, 10);
	
	real_screen = screen;
	VirtualKeyboard_init(screen);
	

	FILE *fichero;
	int i;
	
	for(i=0; i<3; i++)
	{
		switch (i)
		{
#ifdef GEKKO
			case 0:
			fichero=fopen("/uae/wave/menu_navigation_BE.raw","rb"); //Menu up, down, left, right
			break;
		
			case 1:
			fichero=fopen("/uae/wave/select_BE.raw","rb"); //Menu select
			break;
			
			case 2:
			fichero=fopen("/uae/wave/unselect_BE.raw","rb"); //Menu unselect
			break;
#else
			case 0:
			fichero=fopen("/uae/wave/menu_navigation_LE.raw","rb"); //Menu up, down, left, right
			break;
		
			case 1:
			fichero=fopen("/uae/wave/select_LE.raw","rb"); //Menu select
			break;
			
			case 2:
			fichero=fopen("/uae/wave/unselect_LE.raw","rb"); //Menu unselect
			break;
#endif			
		}
		
		
		if(fichero==NULL) {
			write_log("Can't open button click wav file: %d\n", i);
			exit(1);
			}
		
		fseek (fichero, 0, SEEK_END);
		len_click_buffer[i]=ftell (fichero);
		fseek (fichero, 0, SEEK_SET);
	
		click_buffer_pointer[i]= (char *) malloc(len_click_buffer[i]);
	
		if(click_buffer_pointer[i]==NULL) {
			write_log("Can't allocate click wav buffer: %d\n",i);
			exit(1);
			}
		
		fread(click_buffer_pointer[i], 1, len_click_buffer[i], fichero); 	
	
		fclose(fichero);
	}
	
	is_inited = 1;
	DEBUG_LOG("Menu is inited\n");
}