1 #include <stdlib.h>
2 #include "game/gui/menu_background.h"
3 #include "utils/log.h"
4 #include "video/color.h"
5 #include "video/image.h"
6
7 #define COLOR_MENU_LINE color_create(0,0,89,255)
8 #define COLOR_MENU_BORDER color_create(0,0,243,255)
9 #define COLOR_MENU_LINE2 color_create(0,0,125,255)
10 #define COLOR_MENU_BORDER1 color_create(0,158,0,255)
11 #define COLOR_MENU_BORDER2 color_create(0,93,0,255)
12 #define COLOR_MENU_BG color_create(4,4,16,210)
13
menu_background_create(surface * s,int w,int h)14 void menu_background_create(surface *s, int w, int h) {
15 image img;
16 image_create(&img, w, h);
17 image_clear(&img, COLOR_MENU_BG);
18 for(int x = 5; x < w; x += 8) {
19 image_line(&img, x, 0, x, h-1, COLOR_MENU_LINE);
20 }
21 for(int y = 5; y < h; y += 8) {
22 image_line(&img, 0, y, w-1, y, COLOR_MENU_LINE);
23 }
24 image_rect(&img, 0, 0, w-1, h-1, COLOR_MENU_BORDER);
25 surface_create_from_image(s, &img);
26 image_free(&img);
27 }
28
29 // the *other* style menu background
menu_background2_create(surface * s,int w,int h)30 void menu_background2_create(surface *s, int w, int h) {
31 image img;
32 image_create(&img, w, h);
33 image_clear(&img, COLOR_MENU_BG);
34 for(int x = 5; x < w; x += 5) {
35 image_line(&img, x, 0, x, h-1, COLOR_MENU_LINE2);
36 }
37 for(int y = 4; y < h; y += 5) {
38 image_line(&img, 0, y, w-1, y, COLOR_MENU_LINE2);
39 }
40 image_rect(&img, 1, 1, w-2, h-2, COLOR_MENU_BORDER2);
41 image_rect(&img, 0, 0, w-2, h-2, COLOR_MENU_BORDER1);
42 surface_create_from_image(s, &img);
43 image_free(&img);
44 }
45
46 // create a transparent background with only the borders
menu_background_border_create(surface * s,int w,int h)47 void menu_background_border_create(surface *s, int w, int h) {
48 image img;
49 image_create(&img, w, h);
50 image_clear(&img, color_create(0,0,0,0));
51 image_rect(&img, 0, 0, w-1, h-1, COLOR_MENU_BORDER);
52 surface_create_from_image(s, &img);
53 image_free(&img);
54 }
55