Added reload of levels on F7 (Update levelpack) to ease the test of changes.
[enigmagame.git] / src / gui / LevelPackMenu.hh
blob5f28acc0dff0c07bde81d186e33ec40072726bd7
1 /*
2 * Copyright (C) 2002,2003,2004,2005,2006 Daniel Heck, Ronald Lamprecht
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.
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.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 #ifndef GUI_LEVELPACKMENU_HH_INCLUDED
20 #define GUI_LEVELPACKMENU_HH_INCLUDED
22 #include "gui/Menu.hh"
23 #include "video.hh"
24 #include "lev/Index.hh"
26 #include <map>
27 #include <string>
29 namespace enigma { namespace gui {
30 /* -------------------- LevelPackMenu -------------------- */
32 /**
33 * The levelpack selection menu.
35 * The used strategy for horizontal scrolling of the levelpack columns
36 * is to avoid scrolling as long as the target levelpack is still visible.
37 * The current levelpack may be scrolled out of visibility by using the
38 * scoll buttons within this menu. But if the user changes the current
39 * levelpack via indirect methods besides
40 * using the levelpack menu, f.e. the jumpto command, we ensure that
41 * the new current levelpack is visible when the menu is redisplayed.
42 * If it is necessary to scroll we scroll only the minimum amount of columns
43 * needed to display the current levelpack. Even on screen resolution changes
44 * we try to keep the column of the current levelpack unchanged.
46 class LevelPackMenu : public Menu {
47 public:
48 LevelPackMenu();
49 void manageLevelMenu();
50 virtual bool manage();
52 bool on_event (const SDL_Event &e);
53 void on_action(Widget *w);
54 void draw_background(ecl::GC &gc);
56 private:
57 static std::map<std::string, std::string> groupLastSelectedIndex;
58 static std::map<std::string, int> groupLastSelectedColumn;
59 static std::string lastGroupName;
60 static int firstDisplayedGroup;
62 video::VideoModes vm;
63 video::VideoTileType vtt;
64 int vh, vv; // h and v margins due to fullscreen margins
65 std::vector<TextButton *> packButtons;
66 std::vector<TextButton *> groupButtons;
68 HList *packsHList;
69 ImageButton *scrollLeft;
70 ImageButton *scrollRight;
71 ImageButton *scrollUp;
72 ImageButton *scrollDown;
73 VList *groupsVList;
74 HList *commandHList;
75 Widget *but_search;
76 Widget *but_new;
77 Widget *but_level;
78 Widget *but_main;
80 bool isLevelMenuSubmenu;
82 void setupMenu();
83 void updateHighlight();
84 int getGroupPosition(std::vector<std::string> * groups, std::string groupName);
85 int getIndexPosition(std::vector<lev::Index *> * group, std::string indexName);
86 int checkColumn(int rows, int columns, int size, int position, int oldColumn);
88 }} // namespace enigma::gui
89 #endif