1 /*
2 Copyright (C) 1997-2001 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (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.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
19 */
20
21 #include "ui_local.h"
22
23 /*
24 =============================================================================
25
26 ADDRESS BOOK MENU
27
28 =============================================================================
29 */
30
31
32 typedef struct m_addressBook_s {
33 menuFrameWork_t menu;
34 menuField_t fields[MAX_LOCAL_SERVERS];
35 menuStatic_t banner;
36 } m_addressBook_t;
37
38 static m_addressBook_t m_addressBook;
39
SaveChanges(void)40 static void SaveChanges( void ) {
41 char buffer[32];
42 int index;
43
44 for( index = 0; index < MAX_LOCAL_SERVERS; index++ ) {
45 Com_sprintf( buffer, sizeof( buffer ), "adr%d", index );
46 cvar.Set( buffer, m_addressBook.fields[index].field.text );
47 }
48 }
49
AddressBook_MenuCallback(int id,int msg,int param)50 static int AddressBook_MenuCallback( int id, int msg, int param ) {
51 switch( msg ) {
52 case QM_DESTROY:
53 SaveChanges();
54 break;
55 default:
56 break;
57 }
58
59 return QMS_NOTHANDLED;
60 }
61
AddressBook_MenuInit(void)62 static void AddressBook_MenuInit( void ) {
63 char buffer[32];
64 int i, y;
65
66 memset( &m_addressBook, 0, sizeof( m_addressBook ) );
67
68 m_addressBook.menu.callback = AddressBook_MenuCallback;
69
70 y = 64;
71 for( i = 0; i < MAX_LOCAL_SERVERS; i++ ) {
72 Com_sprintf( buffer, sizeof( buffer ), "adr%d", i );
73
74 m_addressBook.fields[i].generic.type = MTYPE_FIELD;
75 m_addressBook.fields[i].generic.name = NULL;
76 m_addressBook.fields[i].generic.x = ( uis.glconfig.vidWidth - 30 * SMALLCHAR_WIDTH ) / 2 - RCOLUMN_OFFSET;
77 m_addressBook.fields[i].generic.y = y;
78 y += MENU_SPACING;
79
80 IF_InitText( &m_addressBook.fields[i].field, 30, 60, cvar.VariableString( buffer ) );
81
82 Menu_AddItem( &m_addressBook.menu, &m_addressBook.fields[i] );
83 }
84
85 UI_SetupDefaultBanner( &m_addressBook.banner, "Address Book" );
86
87 Menu_AddItem( &m_addressBook.menu, &m_addressBook.banner );
88
89
90 }
91
M_Menu_AddressBook_f(void)92 void M_Menu_AddressBook_f( void ) {
93 AddressBook_MenuInit();
94 UI_PushMenu( &m_addressBook.menu );
95 }
96
97