1 /* Pongix - clone of the "Pong" video game with net support
2 * Copyright (C) 2005 - Hugo Ruscitti (see AUTHORS file)
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #include "menu.h"
20 #include "mundo.h"
21
22
menu_iniciar(struct mundo * mundo)23 Menu * menu_iniciar (struct mundo * mundo)
24 {
25 Menu * data;
26
27 data = (Menu *) malloc (sizeof (Menu));
28
29 if (data == NULL)
30 {
31 printf ("No se puede crear el m�dulo Menu\n");
32 return NULL;
33 }
34
35 data->cursor = cursor_iniciar ();
36
37 if (data->cursor == NULL)
38 return NULL;
39
40 data->mundo = mundo;
41
42 return data;
43 }
44
menu_actualizar(Menu * data,Uint8 * teclas)45 void menu_actualizar (Menu * data, Uint8 * teclas)
46 {
47 cursor_actualizar (data->cursor, teclas);
48
49 if (teclas [SDLK_RETURN])
50 {
51 switch (data->cursor->opcion)
52 {
53 case 0:
54 mundo_cambiar_estado (data->mundo, JUEGO);
55 break;
56
57 case 1:
58 mundo_cambiar_estado (data->mundo, SERVIDOR);
59 break;
60
61 case 2:
62 mundo_cambiar_estado (data->mundo, CLIENTE);
63 break;
64
65 case 3:
66 mundo_cambiar_estado (data->mundo, CREDITOS);
67 break;
68
69 case 4:
70 mundo_pantalla_completa (data->mundo);
71 break;
72
73 case 5:
74 mundo_salir (data->mundo);
75 break;
76
77 default:
78 printf ("La opci�n %d no est� disponible\n", \
79 data->cursor->opcion);
80 break;
81 }
82 }
83 }
84
menu_imprimir(Menu * data)85 void menu_imprimir (Menu * data)
86 {
87 fuente_printf (data->mundo->fuente, 150, 100, "Iniciar partida local");
88 fuente_printf (data->mundo->fuente, 150, 150, "Iniciar servidor (red)");
89 fuente_printf (data->mundo->fuente, 150, 200, "Iniciar cliente (red)");
90 fuente_printf (data->mundo->fuente, 150, 250, "Creditos");
91 fuente_printf (data->mundo->fuente, 150, 300, "Pantalla Completa");
92 fuente_printf (data->mundo->fuente, 150, 350, "Salir");
93
94 cursor_imprimir (data->cursor, data->mundo);
95 }
96
menu_reiniciar(Menu * data)97 void menu_reiniciar (Menu * data)
98 {
99 }
100
menu_terminar(Menu * data)101 void menu_terminar (Menu * data)
102 {
103 cursor_terminar (data->cursor);
104 free (data);
105 }
106