int button(int, int, int, int, ALLEGRO_COLOR, float, ALLEGRO_COLOR, int, char*, ALLEGRO_FONT, ALLEGRO_COLOR, ALLEGRO_EVENT, int*, int); int button(int width, int height, int place_x, int place_y, ALLEGRO_COLOR colorU, float boundry, ALLEGRO_COLOR boundry_color, int font_size, char* text, ALLEGRO_FONT *font, ALLEGRO_COLOR font_color, ALLEGRO_EVENT event, int *var, int value) { al_draw_filled_rectangle(place_x-(width/2), place_y-(height/2), place_x+(width/2), place_y+(height/2), colorU); al_draw_rectangle(place_x-(width/2), place_y-(height/2), place_x+(width/2), place_y+(height/2), boundry_color, boundry); al_draw_text(font, font_color, place_x, place_y-(font_size/2), 1, text); if(event.mouse.x >= (place_x-(width/2)) && event.mouse.x <= (place_x+(width/2)) && event.mouse.y >= (place_y-(height/2)) && event.mouse.y <= (place_y+(height/2)) && event.mouse.button & 1) *var = value; return 0; } int bool_button(int width, int height, int place_x, int place_y, ALLEGRO_COLOR colorU, float boundry, ALLEGRO_COLOR boundry_color, int font_size, char* text, ALLEGRO_FONT *font, ALLEGRO_COLOR font_color, ALLEGRO_EVENT event, int *var) { al_draw_filled_rectangle(place_x-(width/2), place_y-(height/2), place_x+(width/2), place_y+(height/2), colorU); al_draw_rectangle(place_x-(width/2), place_y-(height/2), place_x+(width/2), place_y+(height/2), boundry_color, boundry); al_draw_text(font, font_color, place_x, place_y-(font_size/2), 1, text); if(event.mouse.x >= (place_x-(width/2)) && event.mouse.x <= (place_x+(width/2)) && event.mouse.y >= (place_y-(height/2)) && event.mouse.y <= (place_y+(height/2)) && event.mouse.button & 1 && event.type ==ALLEGRO_EVENT_MOUSE_BUTTON_DOWN) *var = !*var; return 0; } int input_field(int x1, int y1, int x2, int y2, ALLEGRO_COLOR colorU, float boundry, ALLEGRO_COLOR boundry_color, ALLEGRO_FONT *font, ALLEGRO_EVENT &event, ALLEGRO_EVENT_QUEUE *ev_queue) { int x=0; al_draw_filled_rounded_rectangle(x1, y1, x2, y2, 10, 10, colorU); al_draw_rounded_rectangle(x1, y1, x2, y2, 10, 10, boundry_color, boundry); if(event.mouse.x >= x1 && event.mouse.x <= x2 && event.mouse.y >= y1 && event.mouse.y <= y2 && event.mouse.button & 1 && event.type == ALLEGRO_EVENT_MOUSE_BUTTON_DOWN) { char str1[256]; str1[0] = NULL; int p=0; while(1) { al_draw_text(font, al_map_rgb(0, 153, 0), x1+5+x, y1+5, 1, "|"); al_wait_for_event(ev_queue, &event); str1[p] = event.keyboard.unichar; p++; str1[p] = NULL; /*switch(event.keyboard.keycode) { case 1: strcat(str1, "a"); break; case 2: strcat(str1, "b"); break; case 3: strcat(str1, "c"); break; case 4: strcat(str1, "d"); break; case 5: strcat(str1, "e"); break; case 6: strcat(str1, "f"); break; case 7: strcat(str1, "g"); break; case 8: strcat(str1, "h"); break; case 9: strcat(str1, "i"); break; case 10: strcat(str1, "j"); break; case 11: strcat(str1, "k"); break; case 12: strcat(str1, "l"); break; case 13: strcat(str1, "m"); break; case 14: strcat(str1, "n"); break; case 15: strcat(str1, "o"); break; case 16: strcat(str1, "p"); break; case 17: strcat(str1, "q"); break; case 18: strcat(str1, "r"); break; case 19: strcat(str1, "s"); break; case 20: strcat(str1, "t"); break; case 21: strcat(str1, "u"); break; case 22: strcat(str1, "v"); break; case 23: strcat(str1, "w"); break; case 24: strcat(str1, "x"); break; case 25: strcat(str1, "y"); break; case 26: strcat(str1, "z"); break; }*/ al_draw_text(font, al_map_rgb(0, 153, 0), x1+10, y1+5, 1, str1); //x+5; //printf("%s", str1); if(event.keyboard.keycode == ALLEGRO_KEY_ENTER) { break; } al_flip_display(); } } return 0; }