MiniDevil As beautiful as a shell
welcome.c
Go to the documentation of this file.
1 /* ************************************************************************** */
2 /* */
3 /* ::: :::::::: */
4 /* welcome.c :+: :+: :+: */
5 /* +:+ +:+ +:+ */
6 /* By: baelgadi <baelgadi@student.42.fr> +#+ +:+ +#+ */
7 /* +#+#+#+#+#+ +#+ */
8 /* Created: 2026/02/17 17:49:34 by zotaj-di #+# #+# */
9 /* Updated: 2026/03/04 04:10:54 by baelgadi ### ########.fr */
10 /* */
11 /* ************************************************************************** */
12 
13 #include "welcome_ui.h"
14 
18 static void init_screen(void)
19 {
20  ft_printf("%s%s", CLEAR_SCREEN, HIDE_CURSOR);
21 }
22 
29 {
30  ft_msleep(800);
32  ft_printf("%s", CLEAR_SCREEN);
33 }
34 
43 {
44  int i;
45  int row;
46 
47  row = t->center_y - 13;
48  i = -1;
49  while (++i < t->width)
50  {
51  print_at_pos(row, i + 1, C_AURA1 "▄" RESET);
52  if (i % 3 == 0)
53  ft_msleep(5);
54  }
55  row = t->center_y + 12;
56  i = t->width;
57  while (--i >= 0)
58  {
59  print_at_pos(row, i + 1, C_AURA1 "▀" RESET);
60  if (i % 3 == 0)
61  ft_msleep(5);
62  }
63 }
64 
68 void draw_welcome(void)
69 {
71 
73  init_screen();
75  ft_msleep(200);
76  animate_title(&t);
77  ft_msleep(300);
78  animate_quote(&t);
79  ft_msleep(400);
80  animate_demon(&t);
81  flash_demon_eyes(&t);
82  ft_msleep(300);
83  animate_credits(&t);
84  animate_loading(&t);
85  cleanup_screen(&t);
86 }
#define CLEAR_SCREEN
Definition: minishell_ui.h:29
#define RESET
Definition: minishell_ui.h:37
Extended terminal info (for welcome screen pos)
Definition: welcome_ui.h:49
int height
Terminal height.
Definition: welcome_ui.h:51
int width
Terminal width.
Definition: welcome_ui.h:50
int center_y
Vertical center row.
Definition: welcome_ui.h:53
static void init_screen(void)
Clear the screen and hide the cursor.
Definition: welcome.c:18
static void cleanup_screen(t_welcome_term *t)
Wait a bit, show the cursor and clear the screen to exit welcome.
Definition: welcome.c:28
static void draw_border_effect(t_welcome_term *t)
Animate top and bottom border sweep across the screen.
Definition: welcome.c:42
void draw_welcome(void)
Draw complete welcome animation sequence and clean up.
Definition: welcome.c:68
void flash_demon_eyes(t_welcome_term *t)
Animate the demon's eyes blinking.
void animate_demon(t_welcome_term *t)
Animate the Demon art with 100ms delay.
Definition: welcome_demon.c:99
void animate_quote(t_welcome_term *t)
Draw the quote inside a decorative box.
void animate_title(t_welcome_term *t)
Animate the title appearing character by character.
void animate_credits(t_welcome_term *t)
Print the credits line centered on the screen.
void animate_loading(t_welcome_term *t)
Animate a progress bar.
Welcome screen structures & prototypes.
#define SHOW_CURSOR
Definition: welcome_ui.h:25
#define C_AURA1
Definition: welcome_ui.h:28
#define HIDE_CURSOR
Definition: welcome_ui.h:24
void ft_msleep(int ms)
Sleep for approximately ms millisecondes using a little trick.
Definition: welcome_utils.c:28
void print_at_pos(int row, int col, const char *str)
Move the terminal cursor to [row, col] and print str.
Definition: welcome_utils.c:77
void get_welcome_term_size(t_welcome_term *t)
Get the terminal size and calculate centre coordinates.
Definition: welcome_utils.c:52