summaryrefslogtreecommitdiffstats
path: root/modules/menu/src/menu_iface.c
blob: 3927ca7c8babf54e0b50caaea1b3986ff2840d91 (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
126
127
128
129
130
131
132
133
/******************************************************************************
 *	Copyright (C) 2015	Alejandro Colomar Andrés		      *
 ******************************************************************************/


/******************************************************************************
 ******* headers **************************************************************
 ******************************************************************************/
	#include <math.h>
	#include <stdbool.h>

	#include "game_iface.h"
	#include "start.h"
	#include "menu_clui.h"
	#include "menu_tui.h"
	#include "menu_gui.h"

	#include "menu_iface.h"


/******************************************************************************
 ******* variables ************************************************************
 ******************************************************************************/
bool				flag_exit;
int				menu_iface_mode;
struct Menu_Iface_Variables	menu_iface_variables;


/******************************************************************************
 ******* main *****************************************************************
 ******************************************************************************/
void	menu_iface_init		(void)
{

	menu_iface_variables.level	= GAME_IFACE_LEVEL_BEGINNER;
	menu_iface_variables.rows	= 8;
	menu_iface_variables.cols	= 8;
	menu_iface_variables.p		= 0.16;
}

void	menu_iface_init_iface	(void)
{

	switch (menu_iface_mode) {
	case MENU_IFACE_CLUI:
		break;
	case MENU_IFACE_TUI:
		break;
	case MENU_IFACE_GUI:
		menu_gui_init();
		break;
	}
}

void	menu_iface_cleanup	(void)
{

	switch (menu_iface_mode) {
	case MENU_IFACE_CLUI:
		break;
	case MENU_IFACE_TUI:
		break;
	case MENU_IFACE_GUI:
		menu_gui_cleanup();
		break;
	}
}

void	menu_iface_board	(int *level, int *rows, int *cols, int *mines)
{

	*level	= menu_iface_variables.level;

	/* size & number of mines */
	switch (*level) {
	case GAME_IFACE_LEVEL_BEGINNER:
		*rows	= GAME_IFACE_LEVEL_BEGINNER_ROWS;
		*cols	= GAME_IFACE_LEVEL_BEGINNER_COLS;
		*mines	= GAME_IFACE_LEVEL_BEGINNER_MINES;
		break;
	case GAME_IFACE_LEVEL_INTERMEDIATE:
		*rows	= GAME_IFACE_LEVEL_INTERMEDIATE_ROWS;
		*cols	= GAME_IFACE_LEVEL_INTERMEDIATE_COLS;
		*mines	= GAME_IFACE_LEVEL_INTERMEDIATE_MINES;
		break;
	case GAME_IFACE_LEVEL_EXPERT:
		*rows	= GAME_IFACE_LEVEL_EXPERT_ROWS;
		*cols	= GAME_IFACE_LEVEL_EXPERT_COLS;
		*mines	= GAME_IFACE_LEVEL_EXPERT_MINES;
		break;
	case GAME_IFACE_LEVEL_EXPERT_INV:
		*rows	= GAME_IFACE_LEVEL_EXPERT_COLS;
		*cols	= GAME_IFACE_LEVEL_EXPERT_ROWS;
		*mines	= GAME_IFACE_LEVEL_EXPERT_MINES;
		break;
	case GAME_IFACE_LEVEL_CUSTOM:
		*rows	= menu_iface_variables.rows;
		*cols	= menu_iface_variables.cols;
		*mines	= menu_iface_variables.p * (*rows) * (*cols);
		/* at least one safe field */
		if ((*mines) == (*rows) * (*cols))
			(*mines)--;
		break;
	}
}

void	menu_iface		(void)
{

	start_mode	= START_RAND;

	if (flag_exit)
		return;

	switch (menu_iface_mode) {
	case MENU_IFACE_FOO:
		break;
	case MENU_IFACE_CLUI:
		menu_clui();
		break;
	case MENU_IFACE_TUI:
		menu_tui();
		break;
	case MENU_IFACE_GUI:
		menu_gui();
		break;
	}
}


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