/* Copyright (c) 2002-2012 Croteam Ltd. This program is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "StdH.h" #include #include "MenuPrinting.h" #include "LevelInfo.h" #include "MLevels.h" void CLevelsMenu::Initialize_t(void) { gm_mgTitle.mg_boxOnScreen = BoxTitle(); gm_mgTitle.mg_strText = TRANS("CHOOSE LEVEL"); gm_lhGadgets.AddTail(gm_mgTitle.mg_lnNode); for (INDEX iLabel = 0; iLabel"); gm_mgManualLevel[i].mg_iInList = -2; } BOOL bHasFirst = FALSE; BOOL bHasLast = FALSE; INDEX ctLabels = _lhFilteredLevels.Count(); INDEX iLabel = 0; FOREACHINLIST(CLevelInfo, li_lnNode, _lhFilteredLevels, itli) { CLevelInfo &li = *itli; INDEX iInMenu = iLabel - gm_iListOffset; if ((iLabel >= gm_iListOffset) && (iLabel<(gm_iListOffset + LEVELS_ON_SCREEN))) { bHasFirst |= (iLabel == 0); bHasLast |= (iLabel == ctLabels - 1); gm_mgManualLevel[iInMenu].mg_strText = li.li_strName; gm_mgManualLevel[iInMenu].mg_fnmLevel = li.li_fnLevel; gm_mgManualLevel[iInMenu].mg_bEnabled = TRUE; gm_mgManualLevel[iInMenu].mg_iInList = iLabel; } iLabel++; } // enable/disable up/down arrows gm_mgArrowUp.mg_bEnabled = !bHasFirst && ctLabels>0; gm_mgArrowDn.mg_bEnabled = !bHasLast && ctLabels>0; } void CLevelsMenu::StartMenu(void) { // set default parameters for the list gm_iListOffset = 0; gm_ctListTotal = _lhFilteredLevels.Count(); gm_iListWantedItem = 0; // for each level INDEX i = 0; FOREACHINLIST(CLevelInfo, li_lnNode, _lhFilteredLevels, itlid) { CLevelInfo &lid = *itlid; // if it is the chosen one if (lid.li_fnLevel == _pGame->gam_strCustomLevel) { // demand focus on it gm_iListWantedItem = i; break; } i++; } CGameMenu::StartMenu(); }