summaryrefslogtreecommitdiffstats
path: root/modules/menu/src/menu_clui.c
blob: 0e8ea316f7fcab79877c224f135666fc157adc2f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/******************************************************************************
 *	Copyright (C) 2018	Alejandro Colomar Andrés		      *
 ******************************************************************************/


/******************************************************************************
 ******* headers **************************************************************
 ******************************************************************************/
	#include "alx_input.h"

	#include "about.h"
//	#include "save.h"
		/* start_switch() */
	#include "start.h"

	#include "menu_clui.h"


/******************************************************************************
 ******* macros ***************************************************************
 ******************************************************************************/
	# define	BUFF_SIZE	(1024)


/******************************************************************************
 ******* static functions *****************************************************
 ******************************************************************************/
static	void	menu_clui_rand		(void);
static	void	menu_clui_custom	(void);
static	void	menu_clui_load		(void);
static	void	menu_clui_start		(void);


/******************************************************************************
 ******* main *****************************************************************
 ******************************************************************************/
void	menu_clui	(void)
{
	char	buff [BUFF_SIZE];
	char	ch;

	ch	= 'n';
	printf("Read 'Disclaimer of warranty'? (yes/NO): ");
	fgets(buff, BUFF_SIZE, stdin);
	sscanf(buff, " %c", &ch);
	if (ch == 'y' || ch == 'Y') {
		puts (" >yes");
		print_share_file(SHARE_DISCLAIMER);
	} else {
		puts (" >NO");
	}

	ch	= 'n';
	printf("Read 'License'? (yes/NO): ");
	fgets(buff, BUFF_SIZE, stdin);
	sscanf(buff, " %c", &ch);
	if (ch == 'y' || ch == 'Y') {
		puts (" >yes");
		print_share_file(SHARE_LICENSE);
	} else {
		puts (" >NO");
	}
#if 0
	printf("Game interface? (NCURSES/text): ");
	scanf(" %c%*s ", &ch);
	if (ch == 't' || ch == 'T') {
		puts (" >text");
		// FIXME
	} else {
		puts (" >NCURSES");
		// FIXME
	}
#endif
	menu_clui_load();
}


/******************************************************************************
 ******* static functions *****************************************************
 ******************************************************************************/
static	void	menu_clui_load		(void)
{
#if 0
	/* File name */ // FIXME
	alx_w_getfname(USER_SAVED_DIR, saved_name, "File name:", saved_name, NULL);
#endif
	menu_clui_start();
}

static	void	menu_clui_start		(void)
{
	puts(" >>START:");
	start_switch();

	char	buff [BUFF_SIZE];
	char	ch;

	ch	= 'm';
	printf("Load again? (MENU/load/exit): ");
	fgets(buff, BUFF_SIZE, stdin);
	sscanf(buff, " %c", &ch);
	if (ch == 'p' || ch == 'P') {
		puts (" >load");
		menu_clui_start();
	} else if (ch == 'e' || ch == 'E') {
		puts (" >exit!");
	} else {
		puts (" >MENU");
		menu_clui();
	}
}


/******************************************************************************
 ******* end of file **********************************************************
 ******************************************************************************/