summaryrefslogtreecommitdiffstats
path: root/src/menu/clui.c
blob: 5e947b798e8e505b48c951ffdb660f33efd5bbbb (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
117
118
119
120
121
122
123
124
125
/******************************************************************************
 *	Copyright (C) 2018	Alejandro Colomar Andrés		      *
 *	SPDX-License-Identifier:	GPL-2.0-only			      *
 ******************************************************************************/


/******************************************************************************
 ******* headers **************************************************************
 ******************************************************************************/
#include "vision-artificial/menu/clui.h"

#include <ctype.h>
#include <stdlib.h>

#include "libalx/base/stdio/get.h"

#include "vision-artificial/about/about.h"
#include "vision-artificial/ctrl/start.h"


/******************************************************************************
 ******* macros ***************************************************************
 ******************************************************************************/


/******************************************************************************
 ******* enums ****************************************************************
 ******************************************************************************/


/******************************************************************************
 ******* structs / unions *****************************************************
 ******************************************************************************/


/******************************************************************************
 ******* variables ************************************************************
 ******************************************************************************/


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


/******************************************************************************
 ******* global functions *****************************************************
 ******************************************************************************/
void	menu_clui	(void)
{
	unsigned char	c;

	c = alx_get_ch("ny", true, true, "Read 'Disclaimer of warranty'? (yes/NO): ",
								NULL, 1);
	if (tolower(c) == 'y') {
		printf(" >yes\n");
		print_share_file(SHARE_DISCLAIMER);
	} else {
		printf(" >NO\n");
	}

	c = alx_get_ch("ny", true, true, "Read 'License'? (yes/NO): ", NULL, 1);
	if (tolower(c) == 'y') {
		printf(" >yes\n");
		print_share_file(SHARE_LICENSE);
	} else {
		printf(" >NO\n");
	}
#if 0
	c = alx_get_ch("nt", true, true, "Game interface? (NCURSES/text): ",
								NULL, 1);
	if (tolower(c) == 't') {
		printf(" >text\n");
		// FIXME
	} else {
		printf(" >NCURSES\n");
		// FIXME
	}
#endif
	menu_clui_load();
}


/******************************************************************************
 ******* static functions (definitions) ***************************************
 ******************************************************************************/
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)
{
	unsigned char	c;

	printf(" >>START:\n");
	start_switch();

	c = alx_get_ch("mle", true, true, "Load again? (MENU/load/exit): ",
								NULL, 1);
	if (tolower(c) == 'l') {
		printf(" >load\n");
		menu_clui_start();
	} else if (tolower(c) == 'e') {
		printf(" >exit!\n");
		exit(EXIT_SUCCESS);
	} else {
		printf(" >MENU\n");
		menu_clui();
	}
}


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