void Object::generate_error_bitmap() { if(testBit(ISMEM_BITMAP)) { bitmap = create_memory_bitmap(); } else { bitmap = al_create_bitmap(w, h); } ALLEGRO_COLOR background = al_color_html("#3f51b5"); ALLEGRO_COLOR shadow = al_color_html("#1a237e"); ALLEGRO_COLOR sign = al_color_html("#ffeb3b"); al_set_target_bitmap(bitmap); al_clear_to_color(background); // Shadow (3 triangles) al_draw_filled_triangle(w / 2.0f, h / 4.0f, w, (h * 3.0f) / 4.0f, w / 2.0f, h, shadow); al_draw_filled_triangle(w, (h * 3.0f) / 4.0f, w, h, w / 2.0f, h, shadow); al_draw_filled_triangle(w / 2.0f, h / 4.0f, w / 2.0f, h, w / 4.0f, (h * 3.0f) / 4.0f, shadow); // Alert sign triangle al_draw_filled_triangle(w / 2.0f, h / 4.0f, ((w * 3.0f) / 4), ((h * 3.0f) / 4.0f), w / 4.0f, ((h * 3.0f) / 4.0f), sign); // Exclamation point al_draw_filled_rectangle((w * 15.0f) / 32.0f, ((h * 14.0f) / 32.0f), ((w * 17.0f) / 32.0f), ((h * 19.0f) / 32.0f), background); al_draw_filled_rectangle((w * 15.0f) / 32.0f, (h * 5.0f) / 8.0f, (w * 17.0f) / 32.0f, (h * 11.0f) / 16.0f, background); al_set_target_backbuffer(al_get_current_display()); }
void draw_horizontal_arrow(float x0, float y0, float x1, float y1, ALLEGRO_COLOR color, float thickness) { float aw = 4; float ah = 2; if(x1<x0) aw *= -1; al_draw_line(x0, y0, x1-aw*thickness, y1, color, thickness); al_draw_filled_triangle(x1, y1, x1-aw*thickness, y0+ah*thickness, x1-aw*thickness, y0-ah*thickness, color); al_draw_filled_triangle(x1, y1, x1-aw*thickness, y0+ah*thickness, x1-aw*thickness, y0-ah*thickness, color); }
void drawSlider(float y,float value,bool glow,const char *str) { float width = .18; float height = .05; float x5 = dx(.5); float x65 = dx(.5+width); float xlerp = dx(lerp(.5,.5+width,value)); float y05 = dy(y+height); al_draw_filled_triangle(x5,y05,x65,y05,x65,dy(y),COLOR_SCND); al_draw_filled_triangle(x5,y05,xlerp,y05,xlerp,dy(lerp(y+height,y,value)),glow?COLOR_HGHL:COLOR_TEXT); al_draw_text(data.font_Regular52,glow?COLOR_HGHL:COLOR_TEXT,px(.49),py(y),ALLEGRO_ALIGN_RIGHT,str); }
void DrawShip(SpaceShip &ship) { al_draw_filled_rectangle(ship.x, ship.y - 9, ship.x + 10, ship.y - 7, al_map_rgb(255, 0, 0)); al_draw_filled_rectangle(ship.x, ship.y + 9, ship.x + 10, ship.y + 7, al_map_rgb(255, 0, 0)); al_draw_filled_triangle(ship.x - 12, ship.y - 17, ship.x +12, ship.y, ship.x - 12, ship.y + 17, al_map_rgb(0, 255, 0)); al_draw_filled_rectangle(ship.x - 12, ship.y - 2, ship.x +15, ship.y + 2, al_map_rgb(0, 0, 255)); }
/**< Função Desenha um triangulo preenchido na Janela */ void Des_Triangulo_preenchido( int desenha_triangulo, ALLEGRO_FONT *fonte, int x1, int y1, int x2, int y2, int x3, int y3) { if (desenha_triangulo == 1) { al_draw_text(fonte, al_map_rgb(255, 255, 255), 320, 70, ALLEGRO_ALIGN_CENTRE, "Precione em 3 pontos:"); al_draw_filled_triangle( x1, y1, x2, y2, x3, y3, al_map_rgb(255, 255, 255)); } }
void drawShip(spaceShip &ship){ //turrets al_draw_filled_rectangle(ship.x,ship.y - 9,ship.x + 10,ship.y - 7,al_map_rgb(255,0,0)); al_draw_filled_rectangle(ship.x,ship.y + 9,ship.x + 10,ship.y + 7,al_map_rgb(255,0,0)); //ship body al_draw_filled_triangle(ship.x - 12,ship.y - 17,ship.x + 12,ship.y,ship.x - 12,ship.y + 17,al_map_rgb(0,255,0)); al_draw_filled_rectangle(ship.x - 12, ship.y - 2,ship.x + 15, ship.y + 2, al_map_rgb(0,0,255)); }
void Triangle::draw_in_another_target() { if(get_filled_status()) al_draw_filled_triangle(_V_pos_x1+_V_cam_pos_x,_V_pos_y1+_V_cam_pos_y, _V_pos_x2+_V_cam_pos_x,_V_pos_y2+_V_cam_pos_y, _V_pos_x3+_V_cam_pos_x,_V_pos_y3+_V_cam_pos_y,_V_color); al_draw_triangle(_V_pos_x1+_V_cam_pos_x,_V_pos_y1+_V_cam_pos_y,_V_pos_x2+_V_cam_pos_x, _V_pos_y2+_V_cam_pos_y,_V_pos_x3+_V_cam_pos_x,_V_pos_y3+_V_cam_pos_y, _V_color,_V_thickness); }
void SpeakingAgent::draw() { // store state placement2d::start_transform(); // background al_draw_filled_rectangle(0, 0, size.x, size.y, color::hex("319cff")); // mouth ALLEGRO_BITMAP *mouth_shape = _get_phoneme_image(Speaker::get_current_phoneme()); if (mouth_shape) al_draw_bitmap(mouth_shape, 0, 10, NULL); // eyes float eye_y = size.y/4; float eye_r = 2.3; float eye_1x = size.x/4; float eye_2x = size.x/4 * 3; if (blink_counter < 0.1) { al_draw_line(eye_1x-eye_r*2, eye_y, eye_1x+eye_r*2, eye_y, color::black, eye_r); al_draw_line(eye_2x-eye_r*2, eye_y, eye_2x+eye_r*2, eye_y, color::black, eye_r); if (blink_counter < 0.0) blink_counter = random_double(2.0, 6.0); } else { al_draw_filled_circle(eye_1x, eye_y, eye_r, color::black); al_draw_filled_circle(eye_2x, eye_y, eye_r, color::black); } blink_counter -= 1.0/60; // words float bx = size.x+size.x/4; float by = -size.y/3; float bw = size.x*2.5; float bh = size.y*0.8; float border_radius = 7; al_draw_filled_rounded_rectangle(bx, by, bx+bw, by+bh, border_radius, border_radius, color::white); float tx = bx+border_radius*4; float ty = by+bh-1; float ts = 20; al_draw_filled_triangle(tx, ty, tx+ts, ty, tx, ty+ts, color::white); std::string word = Speaker::get_current_word(); ALLEGRO_FONT *font = fonts["lacuna.ttf 26"]; if (is_paused()) word = "[PAUSED]"; if (font) al_draw_text(font, color::black, bx+bw/2, by+bh/2-al_get_font_line_height(font)/2, ALLEGRO_ALIGN_CENTRE, word.c_str()); // show stream # //al_draw_text(font, color::white, 0, 0, NULL, tostring(voice->get_current_stream()).c_str()); // restore state placement2d::restore_transform(); //draw_crosshair(x, y, color::white); }
void GameClass::DrawSpike (float x, float y, float xf, float yf) const { if ((xf - x < cTileSize/6) || (rand()%1001 < 0)) { float z = y + 0.2*cTileSize*(rand()%1001)/1000.0; al_draw_filled_triangle((x+xf)/2, z+1, xf, yf, x, yf, cWhite); return; } float xm = x + (xf - x)*(1 + 2*(rand()%1001)/1000.0)/4; DrawSpike( x, y, xm, yf); DrawSpike(xm, y, xf, yf); }
void RenderTarget::drawTriangle(float x1, float y1, float x2, float y2, float x3, float y3, bool fill, const ALLEGRO_COLOR &color) { setAsCurrent(); convertCoords(x1, y1); convertCoords(x2, y2); convertCoords(x3, y3); if (fill) { al_draw_filled_triangle(x1, y1, x2, y2, x3, y3, color); } else { al_draw_triangle(x1, y1, x2, y2, x3, y3, color, CBEnchanted::instance()->gfxInterface->getLineWidth()); } }
void Triangle::draw() { if(get_filled_status()) al_draw_filled_triangle(_V_pos_x1*bitmap_scale_x+_V_cam_pos_x,_V_pos_y1*bitmap_scale_y+_V_cam_pos_y, _V_pos_x2*bitmap_scale_x+_V_cam_pos_x,_V_pos_y2*bitmap_scale_y+_V_cam_pos_y, _V_pos_x3*bitmap_scale_x+_V_cam_pos_x,_V_pos_y3*bitmap_scale_y+_V_cam_pos_y, _V_color); al_draw_triangle(_V_pos_x1*bitmap_scale_x+_V_cam_pos_x,_V_pos_y1*bitmap_scale_y+_V_cam_pos_y, _V_pos_x2*bitmap_scale_x+_V_cam_pos_x,_V_pos_y2*bitmap_scale_y+_V_cam_pos_y, _V_pos_x3*bitmap_scale_x+_V_cam_pos_x,_V_pos_y3*bitmap_scale_y+_V_cam_pos_y, _V_color,_V_thickness*primitives_scale); }
void S_Settings::Draw() { static Bitmap bg(BITMAP_MENU_BACKGROUND); bg.Draw(); al_draw_filled_rounded_rectangle(40, 40, 800-40, 600-40, 10, 10, al_map_rgba(0, 0, 0, 175)); al_draw_textf(Fonts::GetFont(30), al_map_rgb(255,255,255), 800-80, 80, ALLEGRO_ALIGN_RIGHT, GetStr(STR_ACTUAL_F).c_str(), Localization::Instance()->GetCurrentLanguage().c_str()); for (std::vector<RectButton*>::const_iterator itr = _buttons.begin(); itr != _buttons.end(); ++itr) (*itr)->Draw(); _buttons.back()->SetText(GetStr(STR_SOUND)); // this will be the sound button // triangle1 points int ux1 = 570; int uy1 = 182; int ux2 = ux1 + 17; int uy2 = uy1 + 15; int ux3 = ux1 - (ux2 - ux1); int uy3 = uy2; // triangle2 points int bx1 = ux1; int by1 = 261; int bx2 = ux1 + 17; int by2 = by1 - 15; int bx3 = bx1 - (bx2 - bx1); int by3 = by2; al_draw_filled_triangle(ux1, uy1, ux2, uy2, ux3, uy3, al_map_rgb(0, 255, 0)); al_draw_filled_triangle(bx1, by1, bx2, by2, bx3, by3, al_map_rgb(0, 255, 0)); if (BlackJack::Instance()->GetMute()) al_draw_line(0+488, 5+308, Fonts::GetFont(20)->vtable->text_length(Fonts::GetFont(20), al_ustr_new(GetStr(STR_SOUND).c_str()))+488+10, 25+308, al_map_rgb(255,255,255), 2.0); al_draw_text(Fonts::GetFont(25), al_map_rgb(255, 255, 255), 488, 208, 0, GetStr(STR_BET).c_str()); al_draw_textf(Fonts::GetFont(25), al_map_rgb(255, 255, 100), 570, 208, 0, "%2.0f", S_Game::GetBet()); }
int main() { ALLEGRO_DISPLAY *display = NULL; ALLEGRO_FONT* century_gothic24; if(!al_init()) { printf("al_init Failed!\n"); return -1; } if(!al_init_primitives_addon()) { printf("al_init_primitives_addon Failed!\n"); return -1; } display = al_create_display(640, 480); if(!display) { printf("al_create_display Failed!\n"); return -1; } al_init_font_addon(); al_init_ttf_addon(); century_gothic24 = al_load_ttf_font("C:\\Windows\\Fonts\\GOTHIC.TTF" , 24, ALLEGRO_ALIGN_CENTRE); // Paint a hidden screen (a buffer), that we'll apply later. al_clear_to_color(al_map_rgb(0,0,0)); // Draw an ugly red triangle to the buffer. al_draw_filled_triangle(10, 10, 200, 200, 350, 230, al_map_rgb(255,0,0)); // Draw text to the buffer al_draw_text(century_gothic24, al_map_rgb(255,255,255), 550, 440, ALLEGRO_ALIGN_CENTRE, "Hello World!"); // Draw a line to the buffer al_draw_line(400,400,500,34,al_map_rgb(255,255,255), 5); // Draw a circle al_draw_circle(300,300, 50, al_map_rgb(255,255,0), 5); // Draw Eclipse al_draw_filled_ellipse(500, 300, 40, 56, al_map_rgb(255,0,255)); // Draw a rectangle al_draw_rectangle(100,200,200,300,al_map_rgb(0,255,0), 6);s // Draw a polygon al_draw_filled_rectangle(0,480,50,400,al_map_rgb(25,185,35)); al_draw_filled_rectangle(0,480,200,450,al_map_rgb(25,185,35)); // Apply the buffer to the front. al_flip_display(); // Wait for 3 secs. al_rest(10.0); // Destroying the display we created, to avoid memory leaking. al_destroy_display(display); return 0; }
void Dropdown_menu_view::Render(const Widget& widget) const { const Dropdown_menu& dropdown_menu = dynamic_cast<const Dropdown_menu&>(widget); Vector2 p = widget.Get_position(); Vector2 s = widget.Get_size(); ALLEGRO_COLOR text_color = al_map_rgb_f(1, 1, 1); ALLEGRO_COLOR tri_color = al_map_rgb_f(1, 1, 1); ALLEGRO_COLOR edge_color = al_map_rgb_f(0.5, 0.5, 0.5); ALLEGRO_COLOR select_color = al_map_rgb_f(0.0, 0, 0.8); //const Ustring& text = dropdown_menu.Get_text(); float h = al_get_font_line_height(font->Afont()); Menu *child = dynamic_cast<Menu*>(dropdown_menu.Get_child()); if(child) { const Ustring& text = child->Get_option(child->Get_selected_option()); float text_width = font->Get_ustr_width(text.Astring()); al_draw_ustr(font->Afont(), text_color, p.x+6+h/2, p.y+3, 0, text.Astring()); } float top = h*0.25; float middle = h*0.5; float bottom = h*0.75; if(dropdown_menu.Is_open()) { al_draw_filled_triangle(p.x+3, p.y+3+middle, p.x+3+middle, p.y+3+middle, p.x+3+top, p.y+3+bottom, tri_color); al_draw_triangle (p.x+3, p.y+3+middle, p.x+3+middle, p.y+3+middle, p.x+3+top, p.y+3+bottom, edge_color, 0); } else { al_draw_filled_triangle(p.x+3, p.y+3+top, p.x+3+top, p.y+3+middle, p.x+3, p.y+3+bottom, tri_color); al_draw_triangle (p.x+3, p.y+3+top, p.x+3+top, p.y+3+middle, p.x+3, p.y+3+bottom, edge_color, 0); } }
static duk_ret_t js_Triangle(duk_context* ctx) { int x1 = duk_require_int(ctx, 0); int y1 = duk_require_int(ctx, 1); int x2 = duk_require_int(ctx, 2); int y2 = duk_require_int(ctx, 3); int x3 = duk_require_int(ctx, 4); int y3 = duk_require_int(ctx, 5); color_t color = duk_require_sphere_color(ctx, 6); if (!is_skipped_frame()) al_draw_filled_triangle(x1, y1, x2, y2, x3, y3, nativecolor(color)); return 0; }
void shal_draw_filled_triangle(float x1, float y1, float x2, float y2, float x3, float y3, float color_r, float color_g, float color_b, float color_a) { ALLEGRO_COLOR color; color.r = color_r; color.g = color_g; color.b = color_b; color.a = color_a; return al_draw_filled_triangle(x1, y1, x2, y2, x3, y3, color); }
void Mouse::Render() { ALLEGRO_COLOR mouseCol; if( mouseDownButton & 1 ) mouseCol = al_map_rgb( 255, 255, 0 ); else if( mouseDownButton & 2 ) mouseCol = al_map_rgb( 255, 128, 0 ); else mouseCol = al_map_rgb( 255, 255, 255 ); if( isBoxing ) { al_draw_rectangle( min(mouseDownAt.X, Position.X), min(mouseDownAt.Y, Position.Y), max(mouseDownAt.X, Position.X), max(mouseDownAt.Y, Position.Y), mouseCol, 1 ); } al_draw_filled_triangle( Position.X, Position.Y, Position.X + 16, Position.Y + 16, Position.X, Position.Y + 25, mouseCol ); al_draw_triangle( Position.X, Position.Y, Position.X + 16, Position.Y + 16, Position.X, Position.Y + 25, al_map_rgb( 0, 0, 0 ), 1 ); }
void TEnterprise::DrawBaseInfo(const Sector & a_sector,int a_nX, int a_nY) { size_t n = a_sector.m_Starbase.size(); if (n>0) { // plot starbases ALLEGRO_COLOR col; for ( size_t i=0; i<n; i++) { switch(a_sector.m_Starbase[i].m_Member) { case MEM_FEDERATION: col = m_pEngine->m_clWHITE; break; case MEM_KLINGON: col = m_pEngine->m_clRED; break; case MEM_ROMULAN: col = m_pEngine->m_clGREEN; break; default: col = m_pEngine->m_clYELLOW; break; } int x1= a_nX-2; int y1= a_nY-12; int x2= a_nX+6; int y2= a_nY-32; int x3= a_nX+14; int y3= a_nY-12; al_draw_filled_triangle(x1, y1, x2, y2, x3, y3,col); } } }
static void HighFilledPrimitives(int mode) { if (mode == INIT) { } else if (mode == LOGIC) { Theta += Speed; al_build_transform(&MainTrans, ScreenW / 2, ScreenH / 2, 1, 1, Theta); } else if (mode == DRAW) { if (Blend) al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE); else al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_use_transform(&MainTrans); al_draw_filled_triangle(-100, -100, -150, 200, 100, 200, al_map_rgb_f(0.5, 0.7, 0.3)); al_draw_filled_rectangle(20, -50, 200, 50, al_map_rgb_f(0.3, 0.2, 0.6)); al_draw_filled_ellipse(-250, 0, 100, 150, al_map_rgb_f(0.3, 0.3, 0.3)); al_draw_filled_rounded_rectangle(50, -250, 350, -75, 50, 70, al_map_rgb_f(0.4, 0.2, 0)); al_draw_filled_pieslice(200, 125, 50, ALLEGRO_PI / 4, 3 * ALLEGRO_PI / 2, al_map_rgb_f(0.3, 0.3, 0.1)); al_use_transform(&Identity); } }
void gfx_render(int step) { static int last[2] = {0.0, 0.0}; int i, j, scale = MIN(G.w / G.gi.map_size[0], G.h / G.gi.map_size[1]); float cur[2]; ALLEGRO_COLOR colors[] = { al_map_rgb( 0, 0, 0), /* x */ al_map_rgb( 0,200, 0), /* p */ al_map_rgb( 0,150, 0), /* r */ al_map_rgb( 0,100, 0), /* a */ al_map_rgb( 0, 50, 0), /* s */ }; al_clear_to_color(al_map_rgb(0,0,0)); /* tiles */ for (i=0; i<G.gi.map_size[0]; i++) { for (j=0; j<G.gi.map_size[1]; j++) { int map_index = i + j * G.gi.map_size[1]; al_draw_filled_rectangle(scale*i, scale*j, scale*(i + 1), scale*(j + 1), colors[G.gi.mapv[map_index]]); } } /* prizes */ for (i=0; i<G.gi.num_prizes_orig; i++) { float x = G.gi.prizes[i][0] + 0.5; float y = G.gi.prizes[i][1] + 0.5; char buff[255]; if (!G.gi.prizes_visited[i]) al_draw_filled_triangle(scale*(x), scale*(y-0.3), scale*(x+0.3), scale*(y+0.3), scale*(x-0.3), scale*(y+0.3), al_map_rgb(255, 255, 0)); else al_draw_triangle(scale*(x), scale*(y-0.3), scale*(x+0.3), scale*(y+0.3), scale*(x-0.3), scale*(y+0.3), al_map_rgb(255, 255, 0), 1.0); sprintf(buff, "%d", i+1); al_draw_text(G.font, al_map_rgb(0,0,0), scale*x, scale*(y-0.1), ALLEGRO_ALIGN_CENTRE, buff); } /* start */ al_draw_filled_circle((float)scale * (G.gi.start[0]+0.5), (float)scale * (G.gi.start[1]+0.5), scale/3, al_map_rgb(0, 255, 0)); /* end */ al_draw_filled_circle((float)scale * (G.gi.end[0]+0.5), (float)scale * (G.gi.end[1]+0.5), scale/3, al_map_rgb(255, 0, 0)); if (step == MOVE_FRAMES-1) { last[0] = G.gi.cur[0]; last[1] = G.gi.cur[1]; } cur[0] = last[0] + (step * ((float)G.gi.cur[0]-last[0]))/MOVE_FRAMES; cur[1] = last[1] + (step * ((float)G.gi.cur[1]-last[1]))/MOVE_FRAMES; /* player */ al_draw_filled_circle((float)scale * (cur[0]+0.5), (float)scale * (cur[1]+0.5), scale/3, al_map_rgb(0, 0, 255)); al_flip_display(); }
int init_bitmaps(Board *b){ // will load bitmaps from folders named 0, 1,..., 7 // inside the folder "icons", each containing 8 square bitmaps int i,j, k=0; char pathname[1000]; ALLEGRO_PATH *path; ALLEGRO_BITMAP *dispbuf = al_get_target_bitmap(); al_set_target_bitmap(NULL); // this is a workaround for android -- try removing later #ifdef ALLEGRO_ANDROID al_android_set_apk_file_interface(); #endif al_set_target_bitmap(dispbuf); for(i=0;i<b->h+1;i++){ for(j=0;j<b->n; j++){ al_utf8_encode(symbol_char[i][j], BF_CODEPOINT_START+ j + i*b->n); symbol_char[i][j][al_utf8_width(BF_CODEPOINT_START+ j + i*b->n)] = '\0'; } } // create buttons // xxx todo: improve these default_font = al_load_font(DEFAULT_FONT_FILE, 16, 0); if(!default_font) errlog("Error loading default font"); b->info_text_bmp = NULL; b->info_panel.bmp = NULL; // if this fails, buttons will be created anyway at update_bitmaps b->button_bmp[0] = al_load_bitmap("buttons/light-bulb.png"); b->button_bmp[1] = al_load_bitmap("buttons/question.png"); b->button_bmp[2] = al_load_bitmap("buttons/gear.png"); b->button_bmp[3] = al_load_bitmap("buttons/undo.png"); if(b->type_of_tiles == 2) return init_bitmaps_classic(b); if(b->type_of_tiles == 1){ // use bitmaps #ifndef ALLEGRO_ANDROID path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); al_path_cstr(path, '/'); #else path = al_create_path(""); #endif for(j=0; j<b->h; j++){ for(k=0; k<b->n; k++){ snprintf(pathname, 999, "%sicons/%d/%d.png", al_path_cstr(path, '/'), j, k); basic_bmp[j][k] = al_load_bitmap(pathname); if(!basic_bmp[j][k]){ errlog("Error loading %s.", pathname); unload_basic_bmps(b, j,k-1); al_destroy_path(path); return -1; } } } al_destroy_path(path); } // create symbols (alternatively we could load these from files!)) symbol_bmp[SYM_FORBIDDEN] = al_create_bitmap(256, 256); symbol_bmp[SYM_SWAPPABLE] = al_create_bitmap(3*256 + 2*b->clue_unit_space, 256); symbol_bmp[SYM_ONE_SIDE] = al_create_bitmap(256, 256); symbol_bmp[SYM_ONLY_ONE] = al_create_bitmap(256, 3*256); if( (!symbol_bmp[SYM_FORBIDDEN]) || (!symbol_bmp[SYM_SWAPPABLE]) || (!symbol_bmp[SYM_ONE_SIDE]) || !symbol_bmp[SYM_ONLY_ONE]){ fprintf(stderr, "Error creating bitmap.\n"); return -1; } al_set_target_bitmap(symbol_bmp[SYM_FORBIDDEN]); al_clear_to_color(NULL_COLOR); al_draw_line(1, 1, 254, 254, al_map_rgba_f(1,0,0,0.5),4); al_draw_line(1, 254, 254, 1, al_map_rgba_f(1,0,0,0.5),4); al_set_target_bitmap(symbol_bmp[SYM_SWAPPABLE]); al_clear_to_color(NULL_COLOR); al_draw_line(256*0.7,256*0.9, 256*(3-0.7),256*0.9, al_map_rgba_f(1,0,0,0.5), 2); al_draw_filled_triangle(256*0.5,256*0.9, 256*0.7,256, 256*0.7, 256*0.8, al_map_rgba_f(1,0,0,0.35)); al_set_target_bitmap(symbol_bmp[SYM_ONE_SIDE]); al_clear_to_color(NULL_COLOR); al_draw_filled_circle(256/2, 256/2, 0.03*256, WHITE_COLOR); al_draw_filled_circle(256/2 - 0.2*256, 256/2, 0.03*256, WHITE_COLOR); al_draw_filled_circle(256/2 + 0.2*256, 256/2, 0.03*256, WHITE_COLOR); al_set_target_bitmap(symbol_bmp[SYM_ONLY_ONE]); al_clear_to_color(NULL_COLOR); al_draw_filled_triangle(256*0.3, 256, 256*0.7, 256, 256*0.5, 256*0.7, al_map_rgba_f(1,0,0,0.5)); al_draw_filled_triangle(256*0.3, 256, 256*0.7, 256, 256*0.5, 256*1.3, al_map_rgba_f(1,0,0,0.5)); al_draw_line(256*0.5, 256*0.8, 256*0.5, 256*1.2, WHITE_COLOR, 3); al_set_target_bitmap(dispbuf); return 0; }
void draw_ship(SpaceShip *ship) { al_draw_filled_triangle(ship->x, ship->y , ship->x-20 , ship->y+20, ship->x+20, ship->y+20, al_map_rgb(0,0, 255)); }
void ManageMusicsState::Draw() { id_of_first_music_on_page = 28 * page_to_display; /* printing musics */ stringstream ss; for (unsigned int j = 0; j < 7; j++) { switch (j) { case 0: { al_draw_bitmap(manage_music_screen, 0, 0, NULL); } case 1: { al_draw_bitmap(acc1, 0, 0, NULL); } case 2: { al_draw_bitmap(acc2, 0, 0, NULL); } case 3: { al_draw_bitmap(acc3, 0, 0, NULL); } case 4: { al_draw_bitmap(acc4, 0, 0, NULL); } } for (unsigned int i = id_of_first_music_on_page, pos = 0; i < StateControl::GetInstance()->radio.GetMusicsList().size() && i < id_of_first_music_on_page + 28; i++, pos++) { ALLEGRO_COLOR text_color; switch (StateControl::GetInstance()->radio.GetMusicsList()[i].GetAvailability()) { case 1: { text_color = DarkGray; break; } case 0: { text_color = Red; break; } } switch (j) { case 0: { al_draw_text(StateControl::GetInstance()->musics_font, text_color, 154, 24 + (pos * 20), NULL, StateControl::GetInstance()->radio.GetMusicsList()[i].GetTitle().c_str()); break; } case 1: { al_draw_text(StateControl::GetInstance()->musics_font, text_color, 310, 24 + (pos * 20), NULL, StateControl::GetInstance()->radio.GetMusicsList()[i].GetArtist().c_str()); break; } case 2: { al_draw_text(StateControl::GetInstance()->musics_font, text_color, 460, 24 + (pos * 20), NULL, StateControl::GetInstance()->radio.GetMusicsList()[i].GetAlbum().c_str()); break; } case 3: { al_draw_text(StateControl::GetInstance()->musics_font, text_color, 585, 24 + (pos * 20), NULL, StateControl::GetInstance()->radio.GetMusicsList()[i].GetGenre().c_str()); break; } case 4: { al_draw_text(StateControl::GetInstance()->musics_font, text_color, 648, 24 + (pos * 20), NULL, StateControl::GetInstance()->radio.GetMusicsList()[i].GetYear().c_str()); break; } case 5: { ss.str(string()); ss << StateControl::GetInstance()->radio.GetMusicsList()[i].GetLikes(); al_draw_text(StateControl::GetInstance()->musics_font, text_color, 692, 24 + (pos * 20), NULL, ss.str().c_str()); break; } case 6: { ss.str(string()); ss << StateControl::GetInstance()->radio.GetMusicsList()[i].GetDislikes(); al_draw_text(StateControl::GetInstance()->musics_font, text_color, 738, 24 + (pos * 20), NULL, ss.str().c_str()); break; } } } } /* page count */ ss.str(string()); ss << "Page: " << page_to_display + 1 << "/" << last_page + 1; al_draw_text(StateControl::GetInstance()->musics_font, DarkGray, 154, 584, NULL, ss.str().c_str()); ss.str(string()); // clearing stringstream content /* musics count */ ss << StateControl::GetInstance()->radio.GetMusicsList().size() << " songs"; al_draw_text(StateControl::GetInstance()->musics_font, DarkGray, 796, 584, ALLEGRO_ALIGN_RIGHT, ss.str().c_str()); ss.str(string()); // clearing stringstream content /* --- page navigation --- */ /* right arrow hover */ if (480 < StateControl::GetInstance()->mouse_x && StateControl::GetInstance()->mouse_x < 487 && 584 < StateControl::GetInstance()->mouse_y && StateControl::GetInstance()->mouse_y < 596 && page_to_display != last_page) { al_draw_filled_triangle(480, 596, 480, 584, 487, 590, LightGray); } /* right arrow */ else if (page_to_display != last_page) { al_draw_filled_triangle(480, 596, 480, 584, 487, 590, DarkGray); } /* left arrow hover */ if (463 < StateControl::GetInstance()->mouse_x && StateControl::GetInstance()->mouse_x < 470 && 584 < StateControl::GetInstance()->mouse_y && StateControl::GetInstance()->mouse_y < 596 && page_to_display != 0) { al_draw_filled_triangle(470, 596, 470, 584, 463, 590, LightGray); } /* left arrow */ else if (page_to_display != 0) { al_draw_filled_triangle(470, 596, 470, 584, 463, 590, DarkGray); } /* ------ */ /* right mouse button pressed */ if (show_edit_remove_menu || show_edit_add_menu) { /* drawing menu */ if(show_edit_add_menu) { al_draw_bitmap(edit_add_menu, right_click_menu_upper_left_x, right_click_menu_upper_left_y, NULL); } else if (show_edit_remove_menu) { al_draw_bitmap(edit_remove_menu, right_click_menu_upper_left_x, right_click_menu_upper_left_y, NULL); } /* first option hover */ if (right_click_menu_upper_left_x < StateControl::GetInstance()->mouse_x && StateControl::GetInstance()->mouse_x < right_click_menu_upper_left_x + 140 && right_click_menu_upper_left_y < StateControl::GetInstance()->mouse_y && StateControl::GetInstance()->mouse_y < right_click_menu_upper_left_y + 40) { al_draw_line(right_click_menu_upper_left_x + 17, right_click_menu_upper_left_y + 31, right_click_menu_upper_left_x + 55, right_click_menu_upper_left_y + 31, DarkGray, 2.0); } /* second option hover */ else if (right_click_menu_upper_left_x < StateControl::GetInstance()->mouse_x && StateControl::GetInstance()->mouse_x < right_click_menu_upper_left_x + 140 && right_click_menu_upper_left_y + 40 < StateControl::GetInstance()->mouse_y && StateControl::GetInstance()->mouse_y < right_click_menu_upper_left_y + 80) { if(show_edit_add_menu) { al_draw_line(right_click_menu_upper_left_x + 15, right_click_menu_upper_left_y + 71, right_click_menu_upper_left_x + 52, right_click_menu_upper_left_y + 71, DarkGray, 2.0); } else if (show_edit_remove_menu) { al_draw_line(right_click_menu_upper_left_x + 17, right_click_menu_upper_left_y + 71, right_click_menu_upper_left_x + 95, right_click_menu_upper_left_y + 71, DarkGray, 2.0); } } } /* add new music button hover */ if (18 < StateControl::GetInstance()->mouse_x && StateControl::GetInstance()->mouse_x < 134 && 80 < StateControl::GetInstance()->mouse_y && StateControl::GetInstance()->mouse_y < 95) { al_draw_line(18, 96, 134, 96, DarkGray, 1.0); } /* go back button hover */ else if (33 < StateControl::GetInstance()->mouse_x && StateControl::GetInstance()->mouse_x < 120 && 555 < StateControl::GetInstance()->mouse_y && StateControl::GetInstance()->mouse_y < 575) { al_draw_line(33, 575, 120, 575, DarkGray, 1.0); } }
void outputArray (pixel **array, int altura, int largura, int indice, int player_x, int player_x2, int player_y, int player_y2, int tamPixel) { ALLEGRO_COLOR terra = al_map_rgb(110, 60, 40); /* Cores */ ALLEGRO_COLOR agua = al_map_rgb(51, 153, 255); ALLEGRO_COLOR ilha = al_map_rgb(6, 96, 0); ALLEGRO_COLOR canoa = al_map_rgb(51, 51, 51); int i, j; int ilha0 = 999999, ilhaf = 0; /* Variáveis que guardam o começo de uma ilha e o final dela */ int playerSize = tamPixel + largura*0.1; if(playerSize > 30) playerSize = 30; al_clear_to_color(agua); for (i = 0; i < altura; i ++) { /* Imprime uma linha de cada vez */ int TMargemEsquerda = margemEsquerda(array[(i+indice)%altura]); /* Os tamanhos das margens */ int TMargemDireita = margemDireita(array[(i+indice)%altura], largura); /* Desenha a margem esquerda */ al_draw_filled_rectangle(0, tamPixel*i, tamPixel*(TMargemEsquerda - 2), tamPixel*(i+1), terra); j = TMargemEsquerda - 2; /* Desenha o encontro da terra com a água, criando triângulos ou retângulos conforme necessário */ if (tipo(&array[(i+indice+1)%altura][j+2]) == TERRA) { /* Se a linha de baixo era maior */ al_draw_filled_rectangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra); j++; al_draw_filled_triangle(tamPixel*j, tamPixel*i, tamPixel*j, tamPixel*(i+1), tamPixel*(j+1), tamPixel*(i+1), terra); } else if (tipo(&array[(i+indice+1)%altura][j+1]) == TERRA) { /* Se era igual */ al_draw_filled_rectangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra); j++; } else { /* Se era menor */ al_draw_filled_triangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*i, tamPixel*j, tamPixel*(i+1), terra); j++; } /* Descobre onde começa e termina a ilha */ for (j = TMargemEsquerda; j < largura - TMargemDireita - 2; j++) if (tipo(&array[(i+indice)%altura][j]) == TERRA) { if (j < ilha0) ilha0 = j; if (j > ilhaf) ilhaf = j; } if (ilhaf != 0) /* Se existe uma ilha, desenha primeiro as duas partes de água, depois ela em cima */ al_draw_filled_rounded_rectangle(tamPixel*ilha0,tamPixel*i,tamPixel*(ilhaf+1),tamPixel*(i+1),3,3, ilha); ilha0 = 999999; /* Reseta os valores */ ilhaf = 0; /* Desenha o segundo encontro da água com a terra */ if (tipo(&array[(i+indice+1)%altura][j+2]) == AGUA) { j++; al_draw_filled_triangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra); } else if (tipo(&array[(i+indice+1)%altura][j+1]) == AGUA) { j++; al_draw_filled_rectangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra); } else { al_draw_filled_triangle(tamPixel*(j+1), tamPixel*(i+1), tamPixel*(j+1), tamPixel*i, tamPixel*j, tamPixel*(i+1), terra); j++; al_draw_filled_rectangle(tamPixel*j, tamPixel*i, tamPixel*(j+1), tamPixel*(i+1), terra); } /* Desenha a margem direita */ al_draw_filled_rectangle(tamPixel*(largura - TMargemDireita), tamPixel*i, tamPixel*(largura), tamPixel*(i+1), terra); } /* Desenha o jogador na posição correta */ /*al_draw_filled_ellipse(player_x, player_y, playerSize/3, playerSize, canoa);*/ al_draw_line(player_x, player_y, player_x2, player_y2, canoa, 5.0); /* Coloca tudo o que foi desenhado na tela */ al_flip_display(); }
void gui_river_smooth_land(float x1, float y1, float x2, float y2, float x3, float y3) { al_draw_filled_triangle(x1, y1 ,x2, y2, x3, y3, al_map_rgb(139, 69, 19)); }
void gui_river_smooth_water(float x1, float y1, float x2, float y2, float x3, float y3) { al_draw_filled_triangle(x1, y1 ,x2, y2, x3, y3, al_map_rgb(135, 206, 250)); }
void TEnterprise::DrawNavigationLegenda(int a_nX, int a_nY) { al_draw_rectangle(a_nX, a_nY,a_nX+300, a_nY+638,m_pEngine->m_clRED,2); a_nX +=10; a_nY +=20; al_draw_filled_circle(a_nX+15,a_nY+5,5,m_pEngine->m_clWHITE); al_draw_filled_rectangle(a_nX+3,a_nY+3,a_nX+17,a_nY+7,m_pEngine->m_clWHITE); al_draw_filled_rectangle(a_nX,a_nY-3,a_nX+8,a_nY,m_pEngine->m_clWHITE); al_draw_filled_rectangle(a_nX,a_nY+10,a_nX+8,a_nY+13,m_pEngine->m_clWHITE); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY-3, 0,"Enterprise is in this sector"); a_nY +=50; int x1= a_nX; int y1= a_nY; int x2= a_nX+8; int y2= a_nY-20; int x3= a_nX+16; int y3= a_nY; al_draw_filled_triangle(x1, y1, x2, y2, x3, y3,m_pEngine->m_clWHITE); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY-18, 0,"Federation starbase"); a_nY +=40; x1= a_nX; y1= a_nY; x2= a_nX+8; y2= a_nY-20; x3= a_nX+16; y3= a_nY; al_draw_filled_triangle(x1, y1, x2, y2, x3, y3,m_pEngine->m_clRED); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY-18, 0,"Klingon starbase"); a_nY +=40; x1= a_nX; y1= a_nY; x2= a_nX+8; y2= a_nY-20; x3= a_nX+16; y3= a_nY; al_draw_filled_triangle(x1, y1, x2, y2, x3, y3,m_pEngine->m_clGREEN); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY-18, 0,"Romulan starbase"); a_nY +=30; al_draw_filled_circle(a_nX+10, a_nY+20,7,m_pEngine->m_clBLUE); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class B star"); a_nY +=40; al_draw_filled_circle(a_nX+10, a_nY+20,6,m_pEngine->m_clWHITE); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class F star"); a_nY +=40; al_draw_filled_circle(a_nX+10, a_nY+20,8,m_pEngine->m_clYELLOW); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class G star"); a_nY +=40; al_draw_filled_circle(a_nX+10, a_nY+20,10,m_pEngine->m_clRED); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class M star"); a_nY +=50; al_draw_filled_circle(a_nX+10, a_nY+20,2,m_pEngine->m_clRED); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class A planet (Hostile)"); a_nY +=30; al_draw_filled_circle(a_nX+10, a_nY+20,3,m_pEngine->m_clMAGENTA); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class B planet (Hostile)"); a_nY +=30; al_draw_filled_circle(a_nX+10, a_nY+20,2,m_pEngine->m_clBROWN); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class L planet (Marginal)"); a_nY +=30; al_draw_filled_circle(a_nX+10, a_nY+20,4,m_pEngine->m_clYELLOW); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class N planet (Gass Gigant)"); a_nY +=30; al_draw_filled_circle(a_nX+10, a_nY+20,2,m_pEngine->m_clAQUA); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class M1 planet (Terrestrial)"); a_nY +=30; al_draw_filled_circle(a_nX+10, a_nY+20,3,m_pEngine->m_clAQUA); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class M2 planet (Terrestrial)"); a_nY +=30; al_draw_filled_circle(a_nX+10, a_nY+20,4,m_pEngine->m_clAQUA); al_draw_text(FontManager::GetFont(FONT::TEXT),m_pEngine->m_clWHITE, a_nX+30, a_nY+12, 0,"A class M3 planet (Terrestrial)"); }
void DrawingClass::DrawFilledTriangle (float x0, float y0, float x1, float y1, float x2, float y2, int r, int g, int b) { ALLEGRO_COLOR color = al_map_rgb(r, g, b); al_draw_filled_triangle(x0, y0, x1, y1, x2, y2, color); }
void level_draw() { al_clear_to_color(al_map_rgb(255,255,255)); float weight; if (game.height <= 180) { weight = 1; } else { weight = round(game.height/180.0); } //inversa do tamanho do mapa, pra usar como porcentagem double scaleX = 1.0/mapWidth; double scaleY = 1.0/mapHeight; int t; for (int y = 0; y < mapHeight; y++) { for (int x = 0; x < mapWidth; x++) { t = tilemap[y*mapWidth+x]; if (t == 0) { al_draw_filled_rectangle(px(x*scaleX),py(y*scaleY),px((x+1)*scaleX),py((y+1)*scaleY),al_map_rgb(51,51,51)); } else if (t == 1) { al_draw_filled_rectangle(px(x*scaleX),py(y*scaleY),px((x+1)*scaleX),py((y+1)*scaleY),al_map_rgb(204,51,51)); } else if (t == 2) { al_draw_filled_rectangle(px(x*scaleX),py(y*scaleY),px((x+1)*scaleX),py((y+1)*scaleY),al_map_rgb(51,204,51)); } } } //posição do ponto 0 do gráfico double offsetX = scaleX*(baseX+1); double offsetY = scaleY*(baseY+1+lerp(zeroHeight,zeroHeightPrev,easeIn(zeroHeightTempo))); //desenha os eixos BLENDALPHA(); ALLEGRO_COLOR axisColor = al_map_rgba(255,255,255,51); al_draw_line(px(offsetX),py(0),px(offsetX),py(1),axisColor,weight); double gridPos; int gridOffset; if (functionDir > 0) { al_draw_line(px(offsetX),py(offsetY),px(1),py(offsetY),axisColor,weight); gridOffset = 1; while (1) { gridPos = gridOffset*scaleX+offsetX; if (gridPos > 1) break; gridPos = px(gridPos); al_draw_line(gridPos,py(offsetY-scaleY*.125),gridPos,py(offsetY+scaleY*.125),axisColor,weight); gridOffset++; } } else { al_draw_line(px(0),py(offsetY),px(offsetX),py(offsetY),axisColor,weight); gridOffset = floor(-offsetX/scaleX); while (1) { gridPos = gridOffset*scaleX+offsetX; if (gridOffset >= 0 || gridPos > 1) break; gridPos = px(gridPos); al_draw_line(gridPos,py(offsetY-scaleY*.125),gridPos,py(offsetY+scaleY*.125),axisColor,weight); gridOffset++; } } gridOffset = floor(-offsetY/scaleY); while (1) { if (gridOffset == 0) { gridOffset++; continue; } gridPos = gridOffset*scaleY+offsetY; if (gridPos > 1) break; gridPos = py(gridPos); al_draw_line(px(offsetX-scaleX*.125),gridPos,px(offsetX+scaleX*.125),gridPos,axisColor,weight); gridOffset++; } BLENDDEFAULT(); //plota a função if (weightTempo > 0 && cacheCount > 0) { float t = easeIn(plotTempo); float w = easeOut(weightTempo); ALLEGRO_COLOR plotColor = al_map_rgba(255,255,255,w*255); w = ceil(w*weight); double x,xa; BLENDALPHA(); if (functionDir > 0) { for (x = dottedTempo*.25-.125; x < functionEnd; x += .25) { xa = (x < 0)?0:x; al_draw_line( dx(offsetX+xa*scaleX),dy(offsetY-getValueOnCacheLerp(xa,t)*scaleY), dx(offsetX+(x+.125)*scaleX),dy(offsetY-getValueOnCacheLerp(x+.125,t)*scaleY), plotColor,w ); } } else { for (x = -dottedTempo*.25+.125; x > functionStart; x -= .25) { xa = (x > 0)?0:x; al_draw_line( dx(offsetX+xa*scaleX),dy(offsetY-getValueOnCacheLerp(xa,t)*scaleY), dx(offsetX+(x-.125)*scaleX),dy(offsetY-getValueOnCacheLerp(x-.125,t)*scaleY), plotColor,w ); } } BLENDDEFAULT(); } //textbox float textboxHeight = textboxPos?.8:0; BLENDALPHA(); if (input.captureText) { al_draw_filled_rectangle(px(0),py(textboxHeight),px(1),py(.2+textboxHeight),al_map_rgba(255,255,255,204)); } else { al_draw_filled_rectangle(px(0),py(textboxHeight),px(1),py(.2+textboxHeight),al_map_rgba(255,255,255,153)); } BLENDDEFAULT(); int textboxOffsetX = px(.04); int textboxOffsetY = py(.03+textboxHeight); int selOffset; for (int a = 0; 1; a++) { if (input.captureText) { if (input.captureText && a == input.caretPos && input.caretBlink < .5f) { al_draw_line( textboxOffsetX, textboxOffsetY, textboxOffsetX, textboxOffsetY+al_get_font_line_height(data.font_UbuntuB), al_map_rgb(255,255,255),1 ); } if (input.selectionStart != -1 && input.selectionEnd == a) { BLENDALPHA(); al_draw_filled_rectangle( selOffset, textboxOffsetY, textboxOffsetX, textboxOffsetY+al_get_font_line_height(data.font_UbuntuB), al_map_rgba(51,51,51,51) ); BLENDDEFAULT(); } } if (input.text[a] == '\0') break; if (input.selectionStart == a) { selOffset = textboxOffsetX; } textboxChar[0] = input.text[a]; al_draw_text(data.font_UbuntuB,al_map_rgb(51,51,51),textboxOffsetX,textboxOffsetY,ALLEGRO_ALIGN_LEFT,textboxChar); textboxOffsetX += al_get_text_width(data.font_UbuntuB,textboxChar); } if (errorMsgShow) { al_draw_filled_triangle( px(.0135),py(.1797+textboxHeight), px(.0415),py(.1797+textboxHeight), px(.0275),py(.125+textboxHeight), al_map_rgb(255,204,15) ); al_draw_text(data.font_UbuntuR,al_map_rgb(51,51,51),px(.0275),py(.127+textboxHeight),ALLEGRO_ALIGN_CENTRE,"!"); al_draw_text(data.font_UbuntuR,al_map_rgb(51,51,51),px(.05),py(.125+textboxHeight),ALLEGRO_ALIGN_LEFT,MensagemDoErro[errorMsg]); } if (input.captureText) { al_draw_text(data.font_UbuntuB,al_map_rgb(51,51,51),px(.01),textboxOffsetY,ALLEGRO_ALIGN_LEFT,">"); al_draw_text(data.font_UbuntuR,al_map_rgb(51,51,51),px(.99),py(.125+textboxHeight),ALLEGRO_ALIGN_RIGHT,"tab: inverter - enter: fechar"); } else { al_draw_text(data.font_UbuntuB,al_map_rgb(102,102,102),px(.01),textboxOffsetY,ALLEGRO_ALIGN_LEFT,">"); al_draw_text(data.font_UbuntuR,al_map_rgb(51,51,51),px(.99),py(.125+textboxHeight),ALLEGRO_ALIGN_RIGHT,"backspace: voltar - tab: inverter - enter: abrir"); } }
void gui_draw() { // If we were asked to redraw everything, redraw the background as well if (gui.info.must_redraw == TRUE) gui_draw_background(); al_set_target_bitmap(gui_buffer); for (int i = gui.boxes_count - 1; i >= 0; i--) { t_gui_box* b = gui.boxes_z_ordered[i]; const t_frame bb = b->frame; const v2i bb_min = bb.GetMin(); const v2i bb_max = bb.GetMax(); if (!(b->flags & GUI_BOX_FLAGS_ACTIVE)) continue; // Draw widgets for (t_list* widgets = b->widgets; widgets != NULL; widgets = widgets->next) { t_widget *w = (t_widget *)widgets->elem; if (w->enabled && w->type != WIDGET_TYPE_CLOSEBOX) if (w->redraw_func != NULL) w->redraw_func(w); } // Blit content switch (b->type) { case GUI_BOX_TYPE_STANDARD: al_set_target_bitmap(gui_buffer); al_draw_bitmap_region(b->gfx_buffer, 0, 0, bb.size.x + 1, bb.size.y + 1, bb.pos.x, bb.pos.y, 0x0000); break; case GUI_BOX_TYPE_GAME: gamebox_draw(b, screenbuffer); break; } // Draw borders al_set_target_bitmap(gui_buffer); gui_rect(LOOK_ROUND, bb.pos.x - 2, bb.pos.y - 20, bb.pos.x + bb.size.x + 2, bb.pos.y + bb.size.y + 2, COLOR_SKIN_WINDOW_BORDER); al_draw_line(bb.pos.x, bb.pos.y - 1.5f, bb.pos.x + bb.size.x + 1, bb.pos.y - 1.5f, COLOR_SKIN_WINDOW_BORDER, 0); al_draw_line(bb.pos.x, bb.pos.y - 0.5f, bb.pos.x + bb.size.x + 1, bb.pos.y - 0.5f, COLOR_SKIN_WINDOW_BORDER, 0); // Draw resize widget (invisible for game window) if (b->flags & GUI_BOX_FLAGS_ALLOW_RESIZE) { const bool is_resizing = (gui.mouse.focus == GUI_FOCUS_BOX && gui.mouse.focus_box == b && gui.mouse.focus_is_resizing); if (b->type != GUI_BOX_TYPE_GAME || is_resizing) { const int sz = 9; // display size is 9, interaction is 12 const ALLEGRO_COLOR color = is_resizing ? COLOR_SKIN_WINDOW_TEXT_HIGHLIGHT : COLOR_SKIN_WINDOW_TITLEBAR_TEXT_UNACTIVE; al_draw_filled_triangle(bb_max.x+2, bb_max.y+2, bb_max.x+2-sz, bb_max.y+2, bb_max.x+2, bb_max.y+2-sz, color); } } // Draw title bar { t_frame titlebar_frame; titlebar_frame.pos.x = bb.pos.x; titlebar_frame.pos.y = bb.pos.y - 18; titlebar_frame.size.x = bb.size.x; titlebar_frame.size.y = 15; SkinGradient_DrawHorizontal(&Skins_GetCurrentSkin()->gradient_window_titlebar, gui_buffer, &titlebar_frame); // Draw title bar text, with wrapping // Is window the focused one? const ALLEGRO_COLOR color = (i == 0) ? COLOR_SKIN_WINDOW_TITLEBAR_TEXT : COLOR_SKIN_WINDOW_TITLEBAR_TEXT_UNACTIVE; Font_SetCurrent(FONTID_LARGE); if (Font_TextWidth(FONTID_CUR, b->title) <= (bb.size.x - 8)) { Font_Print (FONTID_CUR, b->title, bb.pos.x + 4, bb.pos.y - 17, color); } else { // FIXME-OPT: shit code. char title[256]; int len = strlen(b->title); strcpy(title, b->title); while (Font_TextWidth(FONTID_CUR, title) > (bb.size.x - 17)) title[--len] = EOSTR; strcat(title, ".."); Font_Print(FONTID_CUR, title, bb.pos.x + 4, bb.pos.y - 17, color); } // Draw widgets for (t_list* widgets = b->widgets; widgets != NULL; widgets = widgets->next) { t_widget *w = (t_widget *)widgets->elem; if (w->enabled && w->type == WIDGET_TYPE_CLOSEBOX) if (w->redraw_func != NULL) w->redraw_func(w); } } } // Redraw menus on top of the desktop gui_redraw_menus(); // Update applets that comes after the redraw gui_update_applets_after_redraw(); // Clear global redrawing flag and makes mouse reappear gui.info.must_redraw = FALSE; }