feat: For lillian
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
lulcaaaa
2024-10-30 11:49:43 +01:00
parent ddb7bc3e10
commit e2b29032c0
15 changed files with 62 additions and 41 deletions

View File

@ -1,6 +1,6 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include <err.h>
#include "menus/main_menu.h"
#include "utils/EZ_UI/EZ_utils.h"
@ -11,7 +11,7 @@ char flags = 0;
TTF_Font* main_font;
int main()
int main(void)
{
//SDL Init
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
@ -60,4 +60,4 @@ int main()
SDL_DestroyRenderer(renderer);
SDL_DestroyWindow(window);
SDL_Quit();
}
}

View File

@ -1,8 +1,8 @@
#include <SDL2/SDL_ttf.h>
#include <SDL_ttf.h>
#ifndef GLOBAL_H
#define GLOBAL_H
extern TTF_Font* main_font;
#endif
#endif

View File

@ -5,15 +5,15 @@
#include "../utils/EZ_UI/elements/EZ_image.h"
#include "../utils/EZ_UI/elements/EZ_button.h"
#include "../utils/EZ_UI/elements/EZ_text.h"
#include "../utils/EZ_UI/elements/EZ_drag_select.h"
EZ_DRAWABLE* drawables[4];
EZ_INTERACTIBLE* interactibles[2];
EZ_DRAWABLE* drawables[3];
EZ_INTERACTIBLE* interactibles[1];
void* main_menu_objects[3];
void* main_menu_objects[4];
EZ_MENU main_menu;
void unload_main_menu()
void unload_main_menu(void)
{
for (size_t i = 0; i < 2; i++)
{
@ -31,20 +31,22 @@ void main_menu_process_events(SDL_Window* window, SDL_Renderer* renderer, SDL_Ev
}
}
void button_action()
void button_action(EZ_button* tmp)
{
(void)tmp;
main_menu.drawable_elements[0]->visible = !main_menu.drawable_elements[0]->visible;
}
void load_main_menu(SDL_Renderer* renderer)
{
main_menu.drawable_elements = drawables;
main_menu.drawable_elements_len = 3;
main_menu.drawable_elements_len = 4;
main_menu.interactible_elements = interactibles;
main_menu.interactible_elements_len = 1;
main_menu.interactible_elements_len = 2;
main_menu.process_event = &main_menu_process_events;
main_menu.unload_menu = &unload_main_menu;
//Image
anchore_point main_img_anchore = {
@ -102,4 +104,23 @@ void load_main_menu(SDL_Renderer* renderer)
main_menu.drawable_elements[2] = &main_text->drawable_text;
main_menu_objects[2] = (void*)main_text;
anchore_point main_select_anchore = {
0.3,
0.7,
0.3,
0.7,
0,
0,
0,
0
};
EZ_drag_select* select_butt = EZ_create_drag_select("ButtonBackground.png", renderer, main_select_anchore);
main_menu.drawable_elements[3] = &select_butt->drawable_drag;
main_menu.interactible_elements[1] = &select_butt->interactible_select;
main_menu_objects[3] = (void*)select_butt;
}

View File

@ -7,4 +7,4 @@ extern EZ_MENU main_menu;
void load_main_menu(SDL_Renderer* renderer);
#endif
#endif

View File

@ -1,4 +1,4 @@
#include <SDL2/SDL_image.h>
#include <SDL_image.h>
#include <err.h>
#include "EZ_utils.h"
#include "EZ_manager.h"
@ -74,11 +74,11 @@ int EZ_select_menu(int selected_menu)
return 1;
}
void EZ_unload_menus()
void EZ_unload_menus(void)
{
for (int i = 0; i < menu_len; i++)
{
if (EZ_menus[i].unload_menu != NULL)
EZ_menus[i].unload_menu();
}
}
}

View File

@ -1,4 +1,4 @@
#include <SDL2/SDL.h>
#include <SDL.h>
#ifndef EZ_MANAGER_H
#define EZ_MANAGER_H
@ -11,6 +11,6 @@ void EZ_draw_menu(SDL_Window* window, SDL_Renderer* renderer);
int EZ_select_menu(int selected_menu);
void EZ_unload_menus();
void EZ_unload_menus(void);
#endif
#endif

View File

@ -1,5 +1,5 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>
#include "../Rendering/RenderingUtils.h"
#ifndef EZ_UTILS_H
@ -28,7 +28,7 @@ typedef struct menu
EZ_INTERACTIBLE** interactible_elements;
size_t interactible_elements_len;
void (*process_event)(SDL_Window* window, SDL_Renderer* renderer, SDL_Event*, struct menu*);
void (*unload_menu)();
void (*unload_menu)(void);
}EZ_MENU;
#endif
#endif

View File

@ -67,4 +67,4 @@ EZ_button* EZ_create_button(char* back_img, SDL_Renderer* renderer, anchore_poin
butt->on_button_up = NULL;
return butt;
}
}

View File

@ -1,5 +1,5 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>
#include "../EZ_utils.h"
#include "../../Rendering/RenderingUtils.h"
@ -19,4 +19,4 @@ typedef struct ez_button
EZ_button* EZ_create_button(char* back_img, SDL_Renderer* renderer, anchore_point dst_anchore);
#endif
#endif

View File

@ -114,4 +114,4 @@ EZ_drag_select* EZ_create_drag_select(char* select_img, SDL_Renderer* renderer,
select->on_end_selecting = NULL;
return select;
}
}

View File

@ -20,4 +20,4 @@ typedef struct ez_drag_select
EZ_drag_select* EZ_create_drag_select(char* select_img, SDL_Renderer* renderer, anchore_point dst_anchore);
#endif
#endif

View File

@ -59,4 +59,4 @@ void EZ_edit_image(EZ_image* image, SDL_Surface* surface, SDL_Renderer* renderer
{
image->image_surface = surface;
image->drawable_image.texture = SDL_CreateTextureFromSurface(renderer, surface);
}
}

View File

@ -1,5 +1,5 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL.h>
#include <SDL_image.h>
#include "../EZ_utils.h"
#include "../../Rendering/RenderingUtils.h"
@ -19,4 +19,4 @@ EZ_image* EZ_create_image(SDL_Surface* surface, SDL_Renderer* renderer, anchore_
void EZ_edit_image(EZ_image* image, SDL_Surface* surface, SDL_Renderer* renderer);
#endif
#endif

View File

@ -49,4 +49,4 @@ void EZ_change_text(EZ_text* text_obj, char* text, TTF_Font* font, SDL_Color col
text_obj->drawable_text.texture = texture;
text_obj->text = text;
}
}

View File

@ -1,6 +1,6 @@
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_ttf.h>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_ttf.h>
#include "../EZ_utils.h"
#include "../../Rendering/RenderingUtils.h"
@ -18,4 +18,4 @@ EZ_text* EZ_create_text(char* text, TTF_Font* font, SDL_Color color, SDL_Rendere
void EZ_change_text(EZ_text* text_obj, char* text, TTF_Font* font, SDL_Color color, SDL_Renderer* renderer);
#endif
#endif