core/MenuStyle_Radio.cpp
author Scott Ehlert <ds@alliedmods.net>
Sun Aug 24 04:35:48 2008 +0000 (2008-08-24)
changeset 2237 4403a982ec91
parent 1952 b7aa2b626807
child 2289 44045ead61cd
permissions -rw-r--r--
Improved bot detection slightly. This was meant to go along with the fix for amb1801.
ds@1952
     1
/**
ds@1952
     2
 * vim: set ts=4 :
ds@1952
     3
 * =============================================================================
ds@1952
     4
 * SourceMod
ds@1952
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
ds@1952
     6
 * =============================================================================
ds@1952
     7
 *
ds@1952
     8
 * This program is free software; you can redistribute it and/or modify it under
ds@1952
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1952
    10
 * Free Software Foundation.
ds@1952
    11
 * 
ds@1952
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1952
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1952
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1952
    15
 * details.
ds@1952
    16
 *
ds@1952
    17
 * You should have received a copy of the GNU General Public License along with
ds@1952
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
ds@1952
    19
 *
ds@1952
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1952
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1952
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1952
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1952
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1952
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1952
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1952
    27
 * or <http://www.sourcemod.net/license.php>.
ds@1952
    28
 *
ds@1952
    29
 * Version: $Id$
ds@1952
    30
 */
ds@1952
    31
ds@1952
    32
#include "MenuStyle_Radio.h"
ds@1952
    33
#include "sm_stringutil.h"
ds@1952
    34
#include "UserMessages.h"
ds@1952
    35
#include "GameConfigs.h"
ds@1952
    36
#include "PlayerManager.h"
ds@1952
    37
#if defined MENU_DEBUG
ds@1952
    38
#include "Logger.h"
ds@1952
    39
#endif
ds@1952
    40
ds@1952
    41
extern const char *g_RadioNumTable[];
ds@1952
    42
CRadioStyle g_RadioMenuStyle;
ds@1952
    43
int g_ShowMenuId = -1;
ds@1952
    44
bool g_bRadioInit = false;
ds@1952
    45
unsigned int g_RadioMenuTimeout = 0;
ds@1952
    46
ds@1952
    47
CRadioStyle::CRadioStyle()
ds@1952
    48
{
ds@1952
    49
	m_players = new CRadioMenuPlayer[256+1];
ds@1952
    50
	for (size_t i = 0; i < 256+1; i++)
ds@1952
    51
	{
ds@1952
    52
		m_players[i].Radio_SetIndex(i);
ds@1952
    53
	}
ds@1952
    54
}
ds@1952
    55
ds@1952
    56
void CRadioStyle::OnSourceModAllInitialized()
ds@1952
    57
{
ds@1952
    58
	g_Players.AddClientListener(this);
ds@1952
    59
}
ds@1952
    60
ds@1952
    61
void CRadioStyle::OnSourceModLevelChange(const char *mapName)
ds@1952
    62
{
ds@1952
    63
	if (g_bRadioInit)
ds@1952
    64
	{
ds@1952
    65
		return;
ds@1952
    66
	}
ds@1952
    67
ds@1952
    68
	g_bRadioInit = true;
ds@1952
    69
	const char *msg = g_pGameConf->GetKeyValue("HudRadioMenuMsg");
ds@1952
    70
	if (!msg || msg[0] == '\0')
ds@1952
    71
	{
ds@1952
    72
		return;
ds@1952
    73
	}
ds@1952
    74
ds@1952
    75
	g_ShowMenuId = g_UserMsgs.GetMessageIndex(msg);
ds@1952
    76
ds@1952
    77
	if (!IsSupported())
ds@1952
    78
	{
ds@1952
    79
		return;
ds@1952
    80
	}
ds@1952
    81
ds@1952
    82
	const char *val = g_pGameConf->GetKeyValue("RadioMenuTimeout");
ds@1952
    83
	if (val != NULL)
ds@1952
    84
	{
ds@1952
    85
		g_RadioMenuTimeout = atoi(val);
ds@1952
    86
	}
ds@1952
    87
	else
ds@1952
    88
	{
ds@1952
    89
		g_RadioMenuTimeout = 0;
ds@1952
    90
	}
ds@1952
    91
ds@1952
    92
	g_Menus.AddStyle(this);
ds@1952
    93
	g_Menus.SetDefaultStyle(this);
ds@1952
    94
ds@1952
    95
	g_UserMsgs.HookUserMessage(g_ShowMenuId, this, false);
ds@1952
    96
}
ds@1952
    97
ds@1952
    98
void CRadioStyle::OnSourceModShutdown()
ds@1952
    99
{
ds@1952
   100
	g_Players.RemoveClientListener(this);
ds@1952
   101
	g_UserMsgs.UnhookUserMessage(g_ShowMenuId, this, false);
ds@1952
   102
ds@1952
   103
	while (!m_FreeDisplays.empty())
ds@1952
   104
	{
ds@1952
   105
		delete m_FreeDisplays.front();
ds@1952
   106
		m_FreeDisplays.pop();
ds@1952
   107
	}
ds@1952
   108
}
ds@1952
   109
ds@1952
   110
bool CRadioStyle::IsSupported()
ds@1952
   111
{
ds@1952
   112
	return (g_ShowMenuId != -1);
ds@1952
   113
}
ds@1952
   114
ds@1952
   115
bool CRadioStyle::OnClientCommand(int client, const char *cmdname, const CCommand &cmd)
ds@1952
   116
{
ds@1952
   117
	if (strcmp(cmdname, "menuselect") == 0)
ds@1952
   118
	{
ds@1952
   119
		if (!m_players[client].bInMenu)
ds@1952
   120
		{
ds@1952
   121
			m_players[client].bInExternMenu = false;
ds@1952
   122
			return false;
ds@1952
   123
		}
ds@1952
   124
ds@1952
   125
		int arg = atoi(cmd.Arg(1));
ds@1952
   126
		ClientPressedKey(client, arg);
ds@1952
   127
		return true;
ds@1952
   128
	}
ds@1952
   129
ds@1952
   130
	return false;
ds@1952
   131
}
ds@1952
   132
ds@1952
   133
static unsigned int g_last_holdtime = 0;
ds@1952
   134
static unsigned int g_last_client_count = 0;
ds@1952
   135
static int g_last_clients[256];
ds@1952
   136
ds@1952
   137
void CRadioStyle::OnUserMessage(int msg_id, bf_write *bf, IRecipientFilter *pFilter)
ds@1952
   138
{
ds@1952
   139
	int count = pFilter->GetRecipientCount();
ds@1952
   140
	bf_read br(bf->GetBasePointer(), 3);
ds@1952
   141
ds@1952
   142
	br.ReadWord();
ds@1952
   143
	int c = br.ReadChar();
ds@1952
   144
ds@1952
   145
	g_last_holdtime = (c == -1) ? 0 : (unsigned)c;
ds@1952
   146
ds@1952
   147
	for (int i=0; i<count; i++)
ds@1952
   148
	{
ds@1952
   149
		g_last_clients[g_last_client_count++] = pFilter->GetRecipientIndex(i);
ds@1952
   150
	}
ds@1952
   151
}
ds@1952
   152
ds@1952
   153
void CRadioStyle::OnUserMessageSent(int msg_id)
ds@1952
   154
{
ds@1952
   155
	for (unsigned int i=0; i<g_last_client_count; i++)
ds@1952
   156
	{
ds@1952
   157
		int client = g_last_clients[i];
ds@1952
   158
#if defined MENU_DEBUG
ds@1952
   159
		g_Logger.LogMessage("[SM_MENU] CRadioStyle got ShowMenu (client %d) (bInMenu %d)",
ds@1952
   160
			client,
ds@1952
   161
			m_players[client].bInExternMenu);
ds@1952
   162
#endif
ds@1952
   163
		if (m_players[client].bInMenu)
ds@1952
   164
		{
ds@1952
   165
			_CancelClientMenu(client, MenuCancel_Interrupted, true);
ds@1952
   166
		}
ds@1952
   167
		m_players[client].bInExternMenu = true;
ds@1952
   168
		m_players[client].menuHoldTime = g_last_holdtime;
ds@1952
   169
	}
ds@1952
   170
	g_last_client_count = 0;
ds@1952
   171
}
ds@1952
   172
ds@1952
   173
void CRadioStyle::SendDisplay(int client, IMenuPanel *display)
ds@1952
   174
{
ds@1952
   175
	CRadioDisplay *rDisplay = (CRadioDisplay *)display;
ds@1952
   176
	rDisplay->SendRawDisplay(client, m_players[client].menuHoldTime);
ds@1952
   177
}
ds@1952
   178
ds@1952
   179
IMenuPanel *CRadioStyle::CreatePanel()
ds@1952
   180
{
ds@1952
   181
	return g_RadioMenuStyle.MakeRadioDisplay();
ds@1952
   182
}
ds@1952
   183
ds@1952
   184
IBaseMenu *CRadioStyle::CreateMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner)
ds@1952
   185
{
ds@1952
   186
	return new CRadioMenu(pHandler, pOwner);
ds@1952
   187
}
ds@1952
   188
ds@1952
   189
unsigned int CRadioStyle::GetMaxPageItems()
ds@1952
   190
{
ds@1952
   191
	return 10;
ds@1952
   192
}
ds@1952
   193
ds@1952
   194
const char *CRadioStyle::GetStyleName()
ds@1952
   195
{
ds@1952
   196
	return "radio";
ds@1952
   197
}
ds@1952
   198
ds@1952
   199
CBaseMenuPlayer *CRadioStyle::GetMenuPlayer(int client)
ds@1952
   200
{
ds@1952
   201
	return &m_players[client];
ds@1952
   202
}
ds@1952
   203
ds@1952
   204
CRadioDisplay *CRadioStyle::MakeRadioDisplay(CRadioMenu *menu)
ds@1952
   205
{
ds@1952
   206
	CRadioDisplay *display;
ds@1952
   207
	if (m_FreeDisplays.empty())
ds@1952
   208
	{
ds@1952
   209
		display = new CRadioDisplay();
ds@1952
   210
	}
ds@1952
   211
	else
ds@1952
   212
	{
ds@1952
   213
		display = m_FreeDisplays.front();
ds@1952
   214
		m_FreeDisplays.pop();
ds@1952
   215
		display->Reset();
ds@1952
   216
	}
ds@1952
   217
	return display;
ds@1952
   218
}
ds@1952
   219
ds@1952
   220
IMenuPanel *CRadioStyle::MakeRadioDisplay(const char *str, int keys)
ds@1952
   221
{
ds@1952
   222
	CRadioDisplay *pPanel = MakeRadioDisplay(NULL);
ds@1952
   223
ds@1952
   224
	pPanel->DirectSet(str, keys);
ds@1952
   225
ds@1952
   226
	return pPanel;
ds@1952
   227
}
ds@1952
   228
ds@1952
   229
void CRadioStyle::FreeRadioDisplay(CRadioDisplay *display)
ds@1952
   230
{
ds@1952
   231
	m_FreeDisplays.push(display);
ds@1952
   232
}
ds@1952
   233
ds@1952
   234
CRadioMenuPlayer *CRadioStyle::GetRadioMenuPlayer(int client)
ds@1952
   235
{
ds@1952
   236
	return &m_players[client];
ds@1952
   237
}
ds@1952
   238
ds@1952
   239
void CRadioStyle::ProcessWatchList()
ds@1952
   240
{
ds@1952
   241
	if (!g_RadioMenuTimeout)
ds@1952
   242
	{
ds@1952
   243
		BaseMenuStyle::ProcessWatchList();
ds@1952
   244
		return;
ds@1952
   245
	}
ds@1952
   246
ds@1952
   247
	BaseMenuStyle::ProcessWatchList();
ds@1952
   248
ds@1952
   249
	CRadioMenuPlayer *pPlayer;
ds@1952
   250
	unsigned int max_clients = g_Players.GetMaxClients();
ds@1952
   251
	for (unsigned int i = 1; i <= max_clients; i++)
ds@1952
   252
	{
ds@1952
   253
		pPlayer = GetRadioMenuPlayer(i);
ds@1952
   254
		if (!pPlayer->bInMenu || pPlayer->bInExternMenu)
ds@1952
   255
		{
ds@1952
   256
			continue;
ds@1952
   257
		}
ds@1952
   258
		if (pPlayer->Radio_NeedsRefresh())
ds@1952
   259
		{
ds@1952
   260
			pPlayer->Radio_Refresh();
ds@1952
   261
		}
ds@1952
   262
	}
ds@1952
   263
}
ds@1952
   264
ds@1952
   265
unsigned int CRadioStyle::GetApproxMemUsage()
ds@1952
   266
{
ds@1952
   267
	return sizeof(CRadioStyle) + (sizeof(CRadioMenuPlayer) * 257);
ds@1952
   268
}
ds@1952
   269
ds@1952
   270
CRadioDisplay::CRadioDisplay()
ds@1952
   271
{
ds@1952
   272
	Reset();
ds@1952
   273
}
ds@1952
   274
ds@1952
   275
CRadioDisplay::CRadioDisplay(CRadioMenu *menu)
ds@1952
   276
{
ds@1952
   277
	Reset();
ds@1952
   278
}
ds@1952
   279
ds@1952
   280
bool CRadioDisplay::DrawRawLine(const char *rawline)
ds@1952
   281
{
ds@1952
   282
	m_BufferText.append(rawline);
ds@1952
   283
	m_BufferText.append("\n");
ds@1952
   284
	return true;
ds@1952
   285
}
ds@1952
   286
ds@1952
   287
void CRadioDisplay::Reset()
ds@1952
   288
{
ds@1952
   289
	m_BufferText.assign("");
ds@1952
   290
	m_Title.assign("");
ds@1952
   291
	m_NextPos = 1;
ds@1952
   292
	keys = 0;
ds@1952
   293
}
ds@1952
   294
ds@1952
   295
void CRadioDisplay::DirectSet(const char *str, int keymap)
ds@1952
   296
{
ds@1952
   297
	m_Title.clear();
ds@1952
   298
	m_BufferText.assign(str);
ds@1952
   299
	keys = keymap;
ds@1952
   300
}
ds@1952
   301
ds@1952
   302
unsigned int CRadioDisplay::GetCurrentKey()
ds@1952
   303
{
ds@1952
   304
	return m_NextPos;
ds@1952
   305
}
ds@1952
   306
ds@1952
   307
bool CRadioDisplay::SetCurrentKey(unsigned int key)
ds@1952
   308
{
ds@1952
   309
	if (key < m_NextPos || m_NextPos > 10)
ds@1952
   310
	{
ds@1952
   311
		return false;
ds@1952
   312
	}
ds@1952
   313
ds@1952
   314
	m_NextPos = key;
ds@1952
   315
ds@1952
   316
	return true;
ds@1952
   317
}
ds@1952
   318
ds@1952
   319
bool CRadioDisplay::SendDisplay(int client, IMenuHandler *handler, unsigned int time)
ds@1952
   320
{
ds@1952
   321
	return g_RadioMenuStyle.DoClientMenu(client, this, handler, time);
ds@1952
   322
}
ds@1952
   323
ds@1952
   324
bool CRadioDisplay::SetExtOption(MenuOption option, const void *valuePtr)
ds@1952
   325
{
ds@1952
   326
	return false;
ds@1952
   327
}
ds@1952
   328
ds@1952
   329
IMenuStyle *CRadioDisplay::GetParentStyle()
ds@1952
   330
{
ds@1952
   331
	return &g_RadioMenuStyle;
ds@1952
   332
}
ds@1952
   333
ds@1952
   334
void CRadioDisplay::DrawTitle(const char *text, bool onlyIfEmpty/* =false */)
ds@1952
   335
{
ds@1952
   336
	if (m_Title.size() != 0 && onlyIfEmpty)
ds@1952
   337
	{
ds@1952
   338
		return;
ds@1952
   339
	}
ds@1952
   340
	m_Title.assign(text);
ds@1952
   341
}
ds@1952
   342
ds@1952
   343
unsigned int CRadioDisplay::DrawItem(const ItemDrawInfo &item)
ds@1952
   344
{
ds@1952
   345
	if (m_NextPos > 10 || !CanDrawItem(item.style))
ds@1952
   346
	{
ds@1952
   347
		return 0;
ds@1952
   348
	}
ds@1952
   349
ds@1952
   350
	if (item.style & ITEMDRAW_RAWLINE)
ds@1952
   351
	{
ds@1952
   352
		if (item.style & ITEMDRAW_SPACER)
ds@1952
   353
		{
ds@1952
   354
			m_BufferText.append(" \n");
ds@1952
   355
		} else {
ds@1952
   356
			m_BufferText.append(item.display);
ds@1952
   357
			m_BufferText.append("\n");
ds@1952
   358
		}
ds@1952
   359
		return 0;
ds@1952
   360
	} else if (item.style & ITEMDRAW_SPACER) {
ds@1952
   361
		m_BufferText.append(" \n");
ds@1952
   362
		return m_NextPos++;
ds@1952
   363
	} else if (item.style & ITEMDRAW_NOTEXT) {
ds@1952
   364
		return m_NextPos++;
ds@1952
   365
	}
ds@1952
   366
ds@1952
   367
	if (item.style & ITEMDRAW_DISABLED)
ds@1952
   368
	{
ds@1952
   369
		m_BufferText.append(g_RadioNumTable[m_NextPos]);
ds@1952
   370
		m_BufferText.append(item.display);
ds@1952
   371
		m_BufferText.append("\n");
ds@1952
   372
	} else {
ds@1952
   373
		m_BufferText.append("->");
ds@1952
   374
		m_BufferText.append(g_RadioNumTable[m_NextPos]);
ds@1952
   375
		m_BufferText.append(item.display);
ds@1952
   376
		m_BufferText.append("\n");
ds@1952
   377
		keys |= (1<<(m_NextPos-1));
ds@1952
   378
	}
ds@1952
   379
ds@1952
   380
	return m_NextPos++;
ds@1952
   381
}
ds@1952
   382
ds@1952
   383
bool CRadioDisplay::CanDrawItem(unsigned int drawFlags)
ds@1952
   384
{
ds@1952
   385
	if ((drawFlags & ITEMDRAW_IGNORE) == ITEMDRAW_IGNORE)
ds@1952
   386
	{
ds@1952
   387
		return false;
ds@1952
   388
	}
ds@1952
   389
ds@1952
   390
	if ((drawFlags & ITEMDRAW_DISABLED) && (drawFlags & ITEMDRAW_CONTROL))
ds@1952
   391
	{
ds@1952
   392
		return false;
ds@1952
   393
	}
ds@1952
   394
ds@1952
   395
	return true;
ds@1952
   396
}
ds@1952
   397
ds@1952
   398
void CRadioDisplay::SendRawDisplay(int client, unsigned int time)
ds@1952
   399
{
ds@1952
   400
	int _sel_keys = (keys == 0) ? (1<<9) : keys;
ds@1952
   401
	CRadioMenuPlayer *pPlayer = g_RadioMenuStyle.GetRadioMenuPlayer(client);
ds@1952
   402
	pPlayer->Radio_Init(_sel_keys, m_Title.c_str(), m_BufferText.c_str());
ds@1952
   403
	pPlayer->Radio_Refresh();
ds@1952
   404
}
ds@1952
   405
ds@1952
   406
void CRadioMenuPlayer::Radio_SetIndex(unsigned int index)
ds@1952
   407
{
ds@1952
   408
	m_index = index;
ds@1952
   409
}
ds@1952
   410
ds@1952
   411
bool CRadioMenuPlayer::Radio_NeedsRefresh()
ds@1952
   412
{
ds@1952
   413
	return (gpGlobals->curtime - display_last_refresh >= g_RadioMenuTimeout);
ds@1952
   414
}
ds@1952
   415
ds@1952
   416
void CRadioMenuPlayer::Radio_Init(int keys, const char *title, const char *text)
ds@1952
   417
{
ds@1952
   418
	if (title[0] != '\0')
ds@1952
   419
	{
ds@1952
   420
		display_len = UTIL_Format(display_pkt, 
ds@1952
   421
			sizeof(display_pkt), 
ds@1952
   422
			"%s\n%s", 
ds@1952
   423
			title,
ds@1952
   424
			text);
ds@1952
   425
	}
ds@1952
   426
	else
ds@1952
   427
	{
ds@1952
   428
		display_len = UTIL_Format(display_pkt, 
ds@1952
   429
			sizeof(display_pkt), 
ds@1952
   430
			"%s", 
ds@1952
   431
			text);
ds@1952
   432
	}
ds@1952
   433
	display_keys = keys;
ds@1952
   434
}
ds@1952
   435
ds@1952
   436
void CRadioMenuPlayer::Radio_Refresh()
ds@1952
   437
{
ds@1952
   438
	cell_t players[1] = {m_index};
ds@1952
   439
	char *ptr = display_pkt;
ds@1952
   440
	char save = 0;
ds@1952
   441
	size_t len = display_len;
ds@1952
   442
	unsigned int time;
ds@1952
   443
ds@1952
   444
	/* Compute the new time */
ds@1952
   445
	if (menuHoldTime == 0)
ds@1952
   446
	{
ds@1952
   447
		time = 0;
ds@1952
   448
	}
ds@1952
   449
	else
ds@1952
   450
	{
ds@1952
   451
		time = menuHoldTime - (unsigned int)(gpGlobals->curtime - menuStartTime);
ds@1952
   452
	}
ds@1952
   453
ds@1952
   454
	while (true)
ds@1952
   455
	{
ds@1952
   456
		if (len > 240)
ds@1952
   457
		{
ds@1952
   458
			save = ptr[240];
ds@1952
   459
			ptr[240] = '\0';
ds@1952
   460
		}
ds@1952
   461
		bf_write *buffer = g_UserMsgs.StartMessage(g_ShowMenuId, players, 1, USERMSG_BLOCKHOOKS);
ds@1952
   462
		buffer->WriteWord(display_keys);
ds@1952
   463
		buffer->WriteChar(time ? time : -1);
ds@1952
   464
		buffer->WriteByte( (len > 240) ? 1 : 0 );
ds@1952
   465
		buffer->WriteString(ptr);
ds@1952
   466
		g_UserMsgs.EndMessage();
ds@1952
   467
		if (len > 240)
ds@1952
   468
		{
ds@1952
   469
			ptr[240] = save;
ds@1952
   470
			ptr = &ptr[240];
ds@1952
   471
			len -= 240;
ds@1952
   472
		}
ds@1952
   473
		else
ds@1952
   474
		{
ds@1952
   475
			break;
ds@1952
   476
		}
ds@1952
   477
	}
ds@1952
   478
ds@1952
   479
	display_last_refresh = gpGlobals->curtime;
ds@1952
   480
}
ds@1952
   481
ds@1952
   482
int CRadioDisplay::GetAmountRemaining()
ds@1952
   483
{
ds@1952
   484
	size_t amt = m_Title.size() + 1 + m_BufferText.size();
ds@1952
   485
	if (amt >= 511)
ds@1952
   486
	{
ds@1952
   487
		return 0;
ds@1952
   488
	}
ds@1952
   489
	return (int)(511 - amt);
ds@1952
   490
}
ds@1952
   491
ds@1952
   492
void CRadioDisplay::DeleteThis()
ds@1952
   493
{
ds@1952
   494
	delete this;
ds@1952
   495
}
ds@1952
   496
ds@1952
   497
bool CRadioDisplay::SetSelectableKeys(unsigned int keymap)
ds@1952
   498
{
ds@1952
   499
	keys = (signed)keymap;
ds@1952
   500
	return true;
ds@1952
   501
}
ds@1952
   502
ds@1952
   503
unsigned int CRadioDisplay::GetApproxMemUsage()
ds@1952
   504
{
ds@1952
   505
	return sizeof(CRadioDisplay)
ds@1952
   506
		+ m_BufferText.size()
ds@1952
   507
		+ m_Title.size();
ds@1952
   508
}
ds@1952
   509
ds@1952
   510
CRadioMenu::CRadioMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner) : 
ds@1952
   511
CBaseMenu(pHandler, &g_RadioMenuStyle, pOwner)
ds@1952
   512
{
ds@1952
   513
}
ds@1952
   514
ds@1952
   515
bool CRadioMenu::SetExtOption(MenuOption option, const void *valuePtr)
ds@1952
   516
{
ds@1952
   517
	return false;
ds@1952
   518
}
ds@1952
   519
ds@1952
   520
IMenuPanel *CRadioMenu::CreatePanel()
ds@1952
   521
{
ds@1952
   522
	return g_RadioMenuStyle.MakeRadioDisplay(this);
ds@1952
   523
}
ds@1952
   524
ds@1952
   525
bool CRadioMenu::Display(int client, unsigned int time, IMenuHandler *alt_handler)
ds@1952
   526
{
ds@1952
   527
	return DisplayAtItem(client, time, 0, alt_handler);
ds@1952
   528
}
ds@1952
   529
ds@1952
   530
bool CRadioMenu::DisplayAtItem(int client,
ds@1952
   531
							   unsigned int time,
ds@1952
   532
							   unsigned int start_item,
ds@1952
   533
							   IMenuHandler *alt_handler)
ds@1952
   534
{
ds@1952
   535
#if defined MENU_DEBUG
ds@1952
   536
	g_Logger.LogMessage("[SM_MENU] CRadioMenu::Display(%p) (client %d) (time %d)",
ds@1952
   537
		this,
ds@1952
   538
		client,
ds@1952
   539
		time);
ds@1952
   540
#endif
ds@1952
   541
	if (m_bCancelling)
ds@1952
   542
	{
ds@1952
   543
		return false;
ds@1952
   544
	}
ds@1952
   545
ds@1952
   546
	return g_RadioMenuStyle.DoClientMenu(client,
ds@1952
   547
		this,
ds@1952
   548
		start_item,
ds@1952
   549
		alt_handler ? alt_handler : m_pHandler, 
ds@1952
   550
		time);
ds@1952
   551
}
ds@1952
   552
ds@1952
   553
void CRadioMenu::Cancel_Finally()
ds@1952
   554
{
ds@1952
   555
	g_RadioMenuStyle.CancelMenu(this);
ds@1952
   556
}
ds@1952
   557
ds@1952
   558
unsigned int CRadioMenu::GetApproxMemUsage()
ds@1952
   559
{
ds@1952
   560
	return sizeof(CRadioMenu) + GetBaseMemUsage();
ds@1952
   561
}
ds@1952
   562
ds@1952
   563
const char *g_RadioNumTable[11] = 
ds@1952
   564
{
ds@1952
   565
	"0. ", "1. ", "2. ", "3. ", "4. ", "5. ", "6. ", "7. ", "8. ", "9. ", "0. "
ds@1952
   566
};