void main() { char radius[50]; srand(time(NULL)); allegro_init(); install_keyboard(); set_color_depth(32); set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0); line(screen, 320 , 0, 320, 480, makecol(255,255,0 )); line(screen, 0 , 240, 640, 240, makecol(255,255,0 )); circle (screen, 320,240,300, makecol(0,0,255)); circle (screen, 320,240,200, makecol(0,0,255)); circle (screen, 320,240,100, makecol(0,0,255)); textout_ex(screen, font, "Probabilistic Machine by Tuyama",50,10, makecol(255,0,0), -1); while( !key[KEY_ESC]){ moveCircle(); raddius = sqrt((double)((x-320)*(x-320)+(y-240)*(y-240))); textout_ex(screen, font, "radius: ", 30, 30, makecol(255,0,0), -1); if (t%100==0) { rectfill(screen, 90, 25, 150, 40, makecol(0, 0, 0)); textout_ex(screen, font, itoa(raddius, radius, 10), 100, 30, makecol(255,0,0), -1); } t+=1; } }
void declare_winner() { if(count1==5) { textout_ex( screen, font, "Player 1 Wins!", 280, 150, makecol( 255, 0, 0), makecol( 0, 0, 0)); rest(2000); count1=0; count2=0; ball_x=320; ball_y=240; p1_x = 20; p1_y = 210; p2_x = 620; p2_y = 210; } else if(count2==5) { textout_ex( screen, font, "Player 2 Wins!", 280, 150, makecol( 255, 0, 0), makecol( 0, 0, 0)); rest(2000); count1=0; count2=0; ball_x=320; ball_y=240; p1_x = 20; p1_y = 210; p2_x = 620; p2_y = 210; } }
void muestra_mensaje (const TipoMensaje msg) { printf("Muestro el mensaje -> %s\n",msg); textout_ex( screen, font, " ", 500,550 , makecol( 255, 0, 0), makecol(0, 0, 0)); textout_ex( screen, font, msg, 500,550 , makecol( 255, 255, 0), makecol(0, 0, 0)); }
void draw_menu(BITMAP *scrbuffer, DATAFILE *main_data, struct menuinfo menu, int row, int col) { // function paints a given menu onto the given bitmap char count; color_map = &trans_table; //clear(scrbuffer); blit(main_data[TITLE_PAGE].dat, scrbuffer, 0, 0, 0, 0, SCREEN_W, SCREEN_H); //draw_trans_sprite(scrbuffer, main_data[TITLE_PAGE].dat, 0, 0); if (menu.fontsize == 2) { for (count = 0; count <= menu.num_of_options-1; count++) textout_ex(scrbuffer, main_data[FONTSMALL].dat, menu.option[count], col, row+count*32, GREY+15, -1); // draw a highlight/cursor draw_sprite(scrbuffer, main_data[CURSOR].dat, col-32, row+menu.highlight*32+4); } else if (menu.fontsize == 1) { for (count = 0; count <= menu.num_of_options-1; count++) textout_ex(scrbuffer, font, menu.option[count], col, row+count*16, GREY+15, -1); // draw a highlight/cursor draw_sprite(scrbuffer, main_data[CURSOR].dat, col-32, row+menu.highlight*16); } }
static void dialog_textout(char *string, int x, int y, int color) { textout_ex(screen,fnt_andrus_4,string,x+1, y,makecol(0,0,0),-1); textout_ex(screen,fnt_andrus_4,string,x, y+1,makecol(0,0,0),-1); textout_ex(screen,fnt_andrus_4,string,x+1, y+1,makecol(0,0,0),-1); textout_ex(screen,fnt_andrus_4,string,x, y,color,-1); }
//this thread updates sprite 0 void* playerdraw_thread(void* data) { //get this thread id int my_thread_id = *((int*)data); //thread's main loop while(!GAMEOVER) { //lock the mutex to protect variables if (pthread_mutex_lock(&threadsafe)) textout_ex(buffer,font,"ERROR: thread mutex was locked",0,0,WHITE,0); if(SHOWHEALTH==true) { textprintf_ex(buffer,font,owl->x, owl->y-20,makecol(255,0,0),-1,"%d",owl->health); } //call the owl draw function owl->drawframe(buffer); //unlock the mutex if (pthread_mutex_unlock(&threadsafe)) textout_ex(buffer,font,"ERROR: thread mutex unlock error",0,0,WHITE,0); } // terminate the thread pthread_exit(NULL); return NULL; }
void draw_palette() { int count = 0; //loop counts int count2 = 0; //[note: as relevant names as could be bothered to make] int count3 = 0; int count4 = 0; int columns = 15; //columns,rows, needed to output all colors in default palette int rows = 15; int startx = 10; //x,y position of color output on screen int starty = 10; int tempy = 10; int color = 0; //starting color to output int pixels = 20; //pixels^2 = size of each square acquire_screen(); for(count4 = 0; count4 <= rows; count4++){ //deals with each row of palette output for(count = 0; count <= columns; count++) { //deals with each column of pallete output starty = tempy; for(count3 = 0; count3 <= pixels; count3++) { //outputs pixels for each sqr row for (count2 = 0; count2 <= pixels; count2++) { //for pixels per sample (square) if (color < 256) { putpixel(screen, startx+count2, starty, color); } } starty++; } starty = tempy; //resets starty to correct row value color++; //increments current palette color startx+=pixels; //increments column, plus relevant no. pixels } startx = 10; //resets column start to ten pixels from left tempy+=pixels; //increments row, plus relevant no. pixels } /*Prints the relevant palette name below main output on screen.*/ if (p==0) { textout_ex(screen, font, "desktop palette", 10, 340, 8, -1); textout_ex(screen, font, "default palette", 10, 340, 13, -1); } else { if (p==1) { textout_ex(screen, font, "default palette", 10, 340, 8, -1); textout_ex(screen, font, "desktop palette", 10, 340, 3, -1); } } release_screen(); }
void showWin() { if(x<=5) textout_ex( screen, font, "Player 2 Wins!", 160, 120, makecol( 255, 0, 0), makecol( 0, 255, 0)); if(x>=385) textout_ex( screen, font, "Player 1 Wins!", 160, 120, makecol( 255, 0, 0), makecol( 0, 255, 0)); dir = rand() % 4 + 1; }
/* draw everything */ void render(BITMAP *bmp) { char buf[80]; MATRIX_f roller, camera; int x, y, w, h; float xfront, yfront, zfront; float xup, yup, zup; /* clear the background */ clear(bmp); set_projection_viewport(0, 0, SCREEN_W, SCREEN_H); /* calculate the in-front vector */ xfront = sin(heading) * cos(pitch); yfront = sin(pitch); zfront = cos(heading) * cos(pitch); /* rotate the up vector around the in-front vector by the roll angle */ get_vector_rotation_matrix_f(&roller, xfront, yfront, zfront, roll*128.0/M_PI); apply_matrix_f(&roller, 0, -1, 0, &xup, &yup, &zup); /* build the camera matrix */ get_camera_matrix_f(&camera, xpos, ypos, zpos, /* camera position */ xfront, yfront, zfront, /* in-front vector */ xup, yup, zup, /* up vector */ fov, /* field of view */ aspect); /* aspect ratio */ /* draw the grid of squares */ for (x=0; x<GRID_SIZE; x++) for (y=0; y<GRID_SIZE; y++) draw_square(bmp, &camera, x * TILE_SIZE, y * TILE_SIZE); /* overlay some text */ set_clip_rect(bmp, 0, 0, bmp->w, bmp->h); sprintf(buf, "Field of view: %d (f/F changes)", fov); textout_ex(bmp, font, buf, 0, 16, 255, -1); sprintf(buf, "Aspect ratio: %.2f (a/A changes)", aspect); textout_ex(bmp, font, buf, 0, 24, 255, -1); sprintf(buf, "X position: %.2f (x/X changes)", xpos); textout_ex(bmp, font, buf, 0, 32, 255, -1); sprintf(buf, "Y position: %.2f (y/Y changes)", ypos); textout_ex(bmp, font, buf, 0, 40, 255, -1); sprintf(buf, "Z position: %.2f (z/Z changes)", zpos); textout_ex(bmp, font, buf, 0, 48, 255, -1); sprintf(buf, "Heading: %.2f deg (left/right changes)", DEG(heading)); textout_ex(bmp, font, buf, 0, 56, 255, -1); sprintf(buf, "Pitch: %.2f deg (pgup/pgdn changes)", DEG(pitch)); textout_ex(bmp, font, buf, 0, 64, 255, -1); sprintf(buf, "Roll: %.2f deg (r/R changes)", DEG(roll)); textout_ex(bmp, font, buf, 0, 72, 255, -1); sprintf(buf, "Front vector: %.2f, %.2f, %.2f", xfront, yfront, zfront); textout_ex(bmp, font, buf, 0, 80, 255, -1); sprintf(buf, "Up vector: %.2f, %.2f, %.2f", xup, yup, zup); textout_ex(bmp, font, buf, 0, 88, 255, -1); }
void Editor::draw() { // Background rectfill(buffer, 0, 0, SCREEN_W, SCREEN_H, makecol(255,255,255)); if( saving){ //Create gui textprintf_centre_ex(buffer,font,640,310, makecol(0,0,0),-1,"Save Map Name"); //Input rectangle rectfill(buffer, 400, 408, 892, 452, makecol(0,0,0)); rectfill(buffer, 402, 410, 890, 450, makecol(255,255,255)); // Output the string to the screen textout_ex(buffer, font, edittext.c_str(), 410, 410, makecol(0,0,0), -1); // Draw the caret vline(buffer, text_length(font, edittext.c_str()) + 410 - text_length(font, ".txt") , 412, 448, makecol(0,0,0)); } else if( opening){ //Create gui textprintf_centre_ex(buffer,font,640,310, makecol(0,0,0),-1,"Open Map Name"); //Input rectangle rectfill(buffer, 400, 408, 892, 452, makecol(0,0,0)); rectfill(buffer, 402, 410, 890, 450, makecol(255,255,255)); // Output the string to the screen textout_ex(buffer, font, edittext.c_str(), 410, 410, makecol(0,0,0), -1); // Draw the caret vline(buffer, text_length(font, edittext.c_str()) + 410 - text_length(font, ".txt") , 412, 448, makecol(0,0,0)); } else{ // Draw tiles tile_map -> draw_map( buffer); exampleTile -> draw_tile( buffer, 0, 0, 0); // Map info textprintf_ex(buffer,font,0,80,makecol(255,255,255),makecol(0,0,0),"height-%i width-%i", tile_map -> height, tile_map -> width); if(layer == 1){ textprintf_ex(buffer,font,0,130,makecol(255,255,255),makecol(0,0,0),"Editing Mode: Foreground"); } else if(layer == 0){ textprintf_ex(buffer,font,0,130,makecol(255,255,255),makecol(0,0,0),"Editing Mode: Background"); } // Cursor circlefill(buffer, mouse_x , mouse_y , 10, makecol(0,0,0)); circlefill(buffer, mouse_x , mouse_y, 8, makecol(255,255,255)); } // Draw buffer stretch_sprite( screen, buffer, 0, 0, SCREEN_W, SCREEN_H); }
void checkWin(){ if ( ball_x < p1_x){ textout_ex( screen, font, "Player 2 Wins!", 320, 240, makecol( 255, 0, 0), makecol( 0, 0, 0)); startNew(); } else if ( ball_x > p2_x){ textout_ex( screen, font, "Player 1 Wins!", 320, 240, makecol( 255, 0, 0), makecol( 0, 0, 0)); startNew(); } }
void init_screen_map(screen_t* my_screen){ my_screen->map.x = 0; my_screen->map.y = 0; my_screen->map.w = MAP_W; my_screen->map.h = MAP_H; my_screen->map.background = create_bitmap(my_screen->map.w, my_screen->map.h); clear_to_color(my_screen->map.background, makecol(0,0,0)); textout_centre_ex(my_screen->map.background, font, "--- CAR RACE ----", 400, 200, makecol(204, 0 , 0), makecol(255, 255, 0)); textout_centre_ex(my_screen->map.background, font, "select your map and go!", 400, 208, makecol(204, 0 , 0), makecol(255, 255, 0)); textout_ex(my_screen->map.background, font, "City Map", 336, 250, makecol(255, 255, 255), makecol(204, 0 , 0)); textout_ex(my_screen->map.background, font, "Race Truck", 336, 258, makecol(255, 255, 255), -1); }
void draw_text(BITMAP *bmp, int x, int y, int color, const char *format, ...) { char buf[512]; va_list ap; va_start(ap, format); uvszprintf(buf, sizeof(buf), format, ap); va_end(ap); textout_ex(bmp, gamefont, buf, x, y+1, blend_color(color, makecol(0, 0, 0), 0.5), -1); textout_ex(bmp, gamefont, buf, x, y, color, -1); }
/* draw the identifier of the task activated */ void draw_activation (int numTActive, int idT, int prio, bool verbose){ char str_prio[3]; char str_id[3]; int x; snprintf(str_id,3, "T%d", idT+1); snprintf(str_prio,3, "%d", prio); x = XMIN + ( (strlen("ACTIVATION SEQUENCE = ") + 1) * PIXEL_CHAR ) + ( 3 * numTActive ) * PIXEL_CHAR; pthread_mutex_lock(&mxa); textout_ex(screen, font, str_id, x, BASE1 + 10, FGC, 0); if (verbose) textout_ex(screen, font, str_prio, x, BASE1 + 20, FGC, 0); pthread_mutex_unlock(&mxa); }
void announceWinner() { //announces the winner if( turn == 1){ textout_ex( screen, font, "X Wins!!!!", 300, 240, makecol( 255, 0, 0), makecol( 0, 0, 0)); }else { textout_ex( screen, font, "Y Wins!!!!", 300, 240, makecol( 255, 0, 0), makecol( 0, 0, 0)); } void checkWin() { //checks for a winner } void drawXO() { //draws in the X and O } void moveBox() { //takes input } int main() { //now we actually build it allegro_init(); install_keyboard(); set_color_depth(16); set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0); xSprite = load_bitmap("x.bmp", NULL); oSprite = load_bitmap("o.bmp", NULL); setupBoard(); while(!key[KEY_ESC]){ moveBox(); } destroy_bitmap(xSprite); destroy_bitmap(oSprite); return 0; }
// @TODO rename to draw_allegro? void c_wallet::draw (BITMAP *frame, int color, t_pos x, t_pos y) const { for (const auto ¤cy: m_currency) { std::string text(currency.first + " " + std::to_string(currency.second)); textout_ex(frame, font, text.c_str(), x, y, color, 255); y -= 10; } }
void c_osi2_switch::draw_packet(c_drawtarget &drawtarget, c_layer &layer_any) { double draw_step = 1./static_cast<double>(g_max_anim_frame); const auto & gui = * drawtarget.m_gui; auto layer = dynamic_cast<c_layer_allegro &>(layer_any); BITMAP *frame = layer.m_frame; c_osi2_switch &tmp_osi2_switch = m_world.find_object_by_uuid_as_switch(m_draw_outbox.front().first); const int this_vx = gui.view_x(m_x), this_vy = gui.view_y(m_y); const int next_vx = gui.view_x(tmp_osi2_switch.m_x), next_vy = gui.view_y(tmp_osi2_switch.m_y); t_geo_point A(this_vx,this_vy); t_geo_point B(next_vx,next_vy); t_geo_point between = c_geometry::point_on_line_between_part(A,B,m_draw_outbox.front().second); //_dbg1("DEBUG<<<<: " << between.x << " " << between.y); //_dbg1("Layer_allegro nr: " << layer.m_layer_nr); draw_trans_sprite(frame, c_bitmaps::get_instance().m_package_green, between.x - c_bitmaps::get_instance().m_package_green->w / 2, between.y - c_bitmaps::get_instance().m_package_green->h / 2); std::string send_percent = std::to_string(static_cast<int>(100*m_draw_outbox.front().second)) + "%"; textout_ex(frame, font, send_percent.c_str(), between.x+15, between.y, makecol(0,15,25), -1); if(m_draw_outbox.front().second < 1. && !m_world.get_is_pause()) { m_draw_outbox.front().second += draw_step; } else { m_draw_outbox.pop(); } }
Imagen::Imagen(Fuente *fuente, string texto, int r, int g, int b) { if ( !fuente ) { bitmap = NULL ; throw Error::ExcepcionParametro("Graficos::Imagen::Imagen(Fuente *, string)", 1); } // Creamos el bitmap con el tamaño apropiado bitmap = create_bitmap( text_length(fuente->GetFont(), texto.c_str()), text_height(fuente->GetFont()) ); if (!bitmap) { throw Error::ExcepcionLocalizada("Graficos::Imagen::Imagen(Fuente *, string)", "No se pudo crear el bitmap"); } // Pintamos el texto en el bitmap creado, con el color que trae de "fabrica" // y con el color de fondo trasparente textout_ex(bitmap, fuente->GetFont(), texto.c_str(), 0, 0, makecol(r,g,b), makecol(255,0,255)); // Por defecto una imagen no se pinta con mascara trasparente, pero una // imagen generada por una fuente si que lo hace por defecto. masked = true ; textura = allegro_gl_make_masked_texture(bitmap); w = bitmap->w ; h = bitmap->h ; destroy_bitmap(bitmap); bitmap = NULL ; }
// function pointer for menu graphics void menu_fptr_video(void) { sys_gfx_clear(); textout_ex(buf, font, "Menu stuff goes here", 0,0, makecol(0,255,255), -1); sys_gfx_flip(); }
void draw_button(BITMAP *bmp, int x, int y, int w, int h, int col, const char *txt, bool selected, bool disabled) { int col1 = makecol( minf(255,getr(col)*1.3f), minf(255,getg(col)*1.3f), minf(255,getb(col)*1.3f) ); int col2 = makecol( getr(col)*0.7f, getg(col)*0.7f, getb(col)*0.7f ); int col3 = makecol( minf(255,getr(col)*1.7f), minf(255,getg(col)*1.7f), minf(255,getb(col)*1.7f) ); if(disabled) { col1 = makecol(130,130,130); col2 = makecol(50,50,50); col3 = makecol(170,170,170); col = makecol(100,100,100); } else if(selected) { rect(bmp, x-2,y-2, x+w+3,y+h+3, makecol(210,210,0)); rect(bmp, x-1,y-1, x+w+2,y+h+2, makecol(255,255,0)); col3 = makecol(255,255,255); } rectfill(bmp, x,y, x+w,y+h, col); line(bmp, x,y, x+w,y, col1); line(bmp, x+w,y, x+w,y+h, col1); line(bmp, x,y+1, x+w,y+1, col1); line(bmp, x+w+1,y, x+w+1,y+h, col1); line(bmp, x,y+h, x+w,y+h, col2); line(bmp, x,y, x,y+h, col2); line(bmp, x,y+h+1, x+w,y+h+1, col2); line(bmp, x+1,y, x+1,y+h, col2); textout_ex(bmp, font2, txt, x + (w/2) - (text_length(font2,txt)/2), y + (h/2) - (text_height(font2)/2), col3, -1); }
//----------------------------------------------------------------------------- // Font_Print (int font_id, BITMAP *dst, const char *text, int x, int y, int color); // Print given string with parameters using current font //----------------------------------------------------------------------------- void Font_Print (int font_id, BITMAP *dst, const char *text, int x, int y, int color) { if (font_id == -1) font_id = FontCurrent->id; // textout (dst, Fonts[font_id].library_data, text, x, y, color); textout_ex (dst, Fonts[font_id].library_data, text, x, y, color, -1); }
void ce_game::drawTitle(const char *text, ce_cord center){ //Draw a title dependant on parameters given BITMAP *bmp = create_bitmap(text_length(font, text),text_height(font)); clear_to_color(bmp,makecol(0,0,0)); textout_ex(bmp, font, text, 0, 0, makecol(240,0,240), -1); stretch_blit(bmp,buffer, 0,0,bmp->w, bmp->h, center.x - ((bmp->w*5)/2), center.y - ((bmp->h*5)/2),bmp->w * 5, bmp->h * 5); destroy_bitmap(bmp); }
void saverec( int matrix[][50], int v[][2], int f[]) // this function will write the new record on the file { int i,j,k=0; // counters char filename[] = "sceneryx.txt"; if(scenery_number==-1) { filename[7] = 'x'; } else if(scenery_number==0) { filename[7] = '_'; } else { filename[7] = intchar(scenery_number); } // before, the function will erase the snake on the matrix and the food erase(matrix,v); matrix[f[0]][f[1]] = 0; FILE *scenery; // the pointer of file scenery = fopen(filename,"w"); // opening the file to write /* Writing the matrix */ for(i=0; i<25; i++) // passing through the lines { for(j=0; j<50; j++) { putc(intchar(matrix[i][j]),scenery); // passing through the column } putc('\n',scenery); // at the final of the line, put a newline } /*Writing the record*/ if(score > record) { record = score; for(i=4; i>=0; i--) { putc(intchar(((int)(record/pow(10,i)))%10),scenery); } textout_ex(screen,font,"NEW RECORD!",220,130,0xFFFFFF,0x000000); } else { for(i=4; i>=0; i--) { putc(intchar(((int)(record/pow(10,i)))%10),scenery); } textout_ex(screen,font,"GAME OVER!",220,130,0xFFFFFF,0x000000); } fclose(scenery); }
void DrawHero(Hero h) { if(inited) { if(levelUp) masked_blit(lvlUp->bitmap,buffer,(lvlUp->frame*player.position.w)+lvlUp->frame+1,(lvlUp->row*player.position.h)+lvlUp->row+1,player.position.x,player.position.y+8,player.position.w,player.position.h); masked_blit(player.a->bitmap,buffer,(player.a->frame*player.position.w)+player.a->frame+1,(player.a->row*player.position.h)+player.a->row+1,player.position.x,player.position.y,player.position.w,player.position.h); int percent = (player.maxHp > 0) ? (int)(48 * (player.hp / player.maxHp)) : 0; masked_stretch_blit(hpBar,buffer,0,0,32,32,player.position.x-9,player.position.y - 9, percent , 6); if(UpTimer) textout_ex(buffer,font,"LEVEL UP",UpPos.x,UpPos.y,makecol(0,0,0),-1); if(player.hp > 0 && player.maxHp > 0) { char *t = malloc(32 * sizeof(char)); itoa((int)player.hp,t,10); textout_ex(buffer,font,t,player.position.x,player.position.y+35,makecol(0,0,0),-1); } } }
/*! \brief Show the current console * * Display the current state of the console on the double * buffer. This includes a horizontal line. The console takes * up 320x120 pixels. * \author PH * \param xofs x-offset display position * \param yofs y-offset display position */ void display_console(int xofs, int yofs) { int i, y; if (g_console.on != 1) return; rectfill(double_buffer, xofs, yofs + 120, xofs + 320, yofs + 240, makecol(0,0,0)); hline(double_buffer, xofs, yofs + 120, xofs + 320, makecol(255,255,255)); y = yofs + 240 - 2 * text_height(font); i = 24; while (y > yofs + 120) { if (g_console.lines[i]) { textout_ex(double_buffer, font, g_console.lines[i], xofs, y, makecol(255,255,255), makecol(0,0,0)); } y -= text_height(font); --i; } textout_ex(double_buffer, font, g_console.inputline, xofs, yofs + 240 - text_height(font), makecol(255,255,255), makecol(0,0,0)); rectfill(double_buffer, xofs + text_length(font, g_console.inputline), yofs + 238, xofs + text_length(font, g_console.inputline) + text_length(font, "_"), yofs + 240, makecol(192,192,192)); }
void outnumber( int x, int y, int number) // prints a number by coordinates { int k; char str_number[7]; str_number[5] = str_number[6] = ' '; for(k=0; k<5; k++) { str_number[4-k] = intchar(((int)(number/pow(10,k)))%10); } textout_ex(screen,font,str_number,x,y,0x040428,0xFFFFFF); }
int d_abitmap_list_proc (int msg, DIALOG *d, int c) { if (msg == MSG_DRAW) { BITMAP *bmp = gui_get_screen(); int height, size, i, len, bar, x, y; char *sel = d->dp2; char s[1024]; int c = 0; if (d->flags & D_GOTFOCUS) c = 1; if (d->flags & D_DISABLED) c = 2; (*(char *(*)(int, int *)) d->dp) (-1, &size); height = (d->h - 4) / text_height (font); bar = (size > height); abitmap_draw_area (d, B_LIST, 0, 0, bar ? d->w - 12 : d->w, d->h, 0, 0); if (bar) abitmap_draw_scroller (d, d->d2, size, height); /* draw the contents */ for (i = 0; i < height; i++) { if (d->d2 + i < size) { int fg = theme->bitmaps[B_LIST][c].color; x = d->x + 2; y = d->y + 2 + i * text_height (font); if (d->d2 + i == d->d1 || ((sel) && (sel[d->d2 + i]))) { abitmap_draw_area (d, B_LIST_ITEM, 0, y - d->y, bar ? d->w - 12 : d->w, text_height (font), 0, 0); fg = theme->bitmaps[B_LIST_ITEM][c].color; } ustrzcpy (s, sizeof (s), (*(char *(*)(int, int *)) d->dp) (i + d->d2, NULL)); x += 8; len = ustrlen (s); while (text_length (font, s) >= MAX (d->w - 1 - (bar ? 22 : 11), 1)) { len--; usetat (s, len, 0); } textout_ex (bmp, font, s, x, y, fg, -1); x += text_length (font, s); } } return D_O_K; } return d_list_proc (msg, d, c); }
void DrawText(int x, int y, bool center, char* format, ...) { char text[1000]; va_list ap; va_start(ap, format); uvsprintf(text, format, ap); va_end(ap); if (center) { int width = text_length(font, "x") * strlen(text); x = x - (width / 2); } textout_ex(buffer, font, text, x-1, y, makecol(0, 0, 0), -1); textout_ex(buffer, font, text, x+1, y, makecol(0, 0, 0), -1); textout_ex(buffer, font, text, x, y-1, makecol(0, 0, 0), -1); textout_ex(buffer, font, text, x, y+1, makecol(0, 0, 0), -1); int text_color = makecol(configuration.colors[COLOR_TEXT].r, configuration.colors[COLOR_TEXT].g, configuration.colors[COLOR_TEXT].b); textout_ex(buffer, font, text, x, y, text_color, -1); }
void draw_text(BITMAP *bmp, int x, int y, int w, int h, int color, const char *format, ...) { if (w > 0 && h > 0) { char buf[512]; va_list ap; va_start(ap, format); uvszprintf(buf, sizeof(buf), format, ap); va_end(ap); BITMAP *tmp = create_bitmap(text_length(gamefont, buf), text_height(gamefont)+1); clear_to_color(tmp, bitmap_mask_color(tmp)); textout_ex(tmp, gamefont, buf, 0, 1, blend_color(color, makecol(0, 0, 0), 0.5), -1); textout_ex(tmp, gamefont, buf, 0, 0, color, -1); masked_stretch_blit(tmp, bmp, 0, 0, tmp->w, tmp->h, x, y, w, h); destroy_bitmap(tmp); } }
// modeACT={MOD_NOW=0, MOD_DEF_OFFSET=1, MOD_DEF_NO_OFFS = 2} void draw_Timetask_info(int modeACT) { int i; int y_inizio_vline = BASE1 + 3 * ALT_RIGA + ALT_MEZZARIGA; vline(screen, X_LINE_VERT0, y_inizio_vline, YMAX1-10, FGC); vline(screen, X_LINE_VERT1, y_inizio_vline, YMAX1-10, FGC); vline(screen, X_LINE_VERT2, y_inizio_vline, YMAX1-10, FGC); hline(screen, XMIN , Y_ORRIZ_LINE , XMAX -5, FGC); if (modeACT == MOD_DEF_OFFSET) { textout_ex(screen, font, "Time offset(ms) inseriti = ", XMIN, BASE1 + 2 * ALT_RIGA, FGC, 0); } textout_ex(screen, font, "TIME ACTIVATION(ms)", X_LINE_VERT0 + 5, Y_ORRIZ_LINE - ALT_RIGA, FGC, 0); textout_ex(screen, font, "TIME START(ms)", X_LINE_VERT1 + 5, Y_ORRIZ_LINE - ALT_RIGA, FGC, 0); textout_ex(screen, font, "TIME OFFSET measured(ms)", X_LINE_VERT2 + 5 , Y_ORRIZ_LINE - ALT_RIGA, FGC, 0); for(i = 0; i < NUM_T_TEST; i++ ) { textprintf_ex(screen, font, XMIN, Y_TIMES + i * ALT_RIGA,FGC, BGC, "T%d:", i+1); } }