1.1 --- a/core/MenuStyle_Radio.cpp Sun Jul 01 12:05:21 2012 -0400
1.2 +++ b/core/MenuStyle_Radio.cpp Mon Jul 02 10:57:22 2012 -0400
1.3 @@ -45,6 +45,14 @@
1.4 bool g_bRadioInit = false;
1.5 unsigned int g_RadioMenuTimeout = 0;
1.6
1.7 +// back, next, exit
1.8 +#define MAX_PAGINATION_OPTIONS 3
1.9 +
1.10 +#define MAX_MENUSLOT_KEYS 10
1.11 +
1.12 +static unsigned int s_RadioMaxPageItems = MAX_MENUSLOT_KEYS;
1.13 +
1.14 +
1.15 CRadioStyle::CRadioStyle()
1.16 {
1.17 m_players = new CRadioMenuPlayer[256+1];
1.18 @@ -90,6 +98,18 @@
1.19 g_RadioMenuTimeout = 0;
1.20 }
1.21
1.22 + const char *items = g_pGameConf->GetKeyValue("RadioMenuMaxPageItems");
1.23 + if (items != NULL)
1.24 + {
1.25 + int value = atoi(items);
1.26 +
1.27 + // Only override the mostly-safe default if it's a sane value
1.28 + if (value > MAX_PAGINATION_OPTIONS && value <= MAX_MENUSLOT_KEYS)
1.29 + {
1.30 + s_RadioMaxPageItems = value;
1.31 + }
1.32 + }
1.33 +
1.34 g_Menus.AddStyle(this);
1.35 g_Menus.SetDefaultStyle(this);
1.36
1.37 @@ -189,7 +209,7 @@
1.38
1.39 unsigned int CRadioStyle::GetMaxPageItems()
1.40 {
1.41 - return 10;
1.42 + return s_RadioMaxPageItems;
1.43 }
1.44
1.45 const char *CRadioStyle::GetStyleName()
1.46 @@ -307,7 +327,7 @@
1.47
1.48 bool CRadioDisplay::SetCurrentKey(unsigned int key)
1.49 {
1.50 - if (key < m_NextPos || m_NextPos > 10)
1.51 + if (key < m_NextPos || m_NextPos > s_RadioMaxPageItems)
1.52 {
1.53 return false;
1.54 }
1.55 @@ -343,7 +363,7 @@
1.56
1.57 unsigned int CRadioDisplay::DrawItem(const ItemDrawInfo &item)
1.58 {
1.59 - if (m_NextPos > 10 || !CanDrawItem(item.style))
1.60 + if (m_NextPos > s_RadioMaxPageItems || !CanDrawItem(item.style))
1.61 {
1.62 return 0;
1.63 }
1.64 @@ -511,6 +531,7 @@
1.65 CRadioMenu::CRadioMenu(IMenuHandler *pHandler, IdentityToken_t *pOwner) :
1.66 CBaseMenu(pHandler, &g_RadioMenuStyle, pOwner)
1.67 {
1.68 + m_Pagination = s_RadioMaxPageItems - MAX_PAGINATION_OPTIONS;
1.69 }
1.70
1.71 bool CRadioMenu::SetExtOption(MenuOption option, const void *valuePtr)
1.72 @@ -551,6 +572,17 @@
1.73 time);
1.74 }
1.75
1.76 +bool CRadioMenu::SetPagination(unsigned int itemsPerPage)
1.77 +{
1.78 + const unsigned int maxPerPage = s_RadioMaxPageItems - MAX_PAGINATION_OPTIONS;
1.79 + if (itemsPerPage > maxPerPage)
1.80 + {
1.81 + return false;
1.82 + }
1.83 +
1.84 + return CBaseMenu::SetPagination(itemsPerPage);
1.85 +}
1.86 +
1.87 void CRadioMenu::Cancel_Finally()
1.88 {
1.89 g_RadioMenuStyle.CancelMenu(this);