Sprite action work for powerup hats: climbing, backflip.
[supertux.git] / src / gui / menu_item.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (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.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_GUI_MENU_ITEM_HPP
18 #define HEADER_SUPERTUX_GUI_MENU_ITEM_HPP
19
20 #include <list>
21 #include <memory>
22 #include <SDL.h>
23
24 #include "gui/menu.hpp"
25
26 /* Kinds of menu items */
27 enum MenuItemKind {
28   MN_ACTION,
29   MN_GOTO,
30   MN_TOGGLE,
31   MN_BACK,
32   MN_INACTIVE,
33   MN_TEXTFIELD,
34   MN_NUMFIELD,
35   MN_CONTROLFIELD,
36   MN_STRINGSELECT,
37   MN_LABEL,
38   MN_HL /* horizontal line */
39 };
40
41 class MenuItem
42 {
43 public:
44   static MenuItem* create(MenuItemKind kind, const std::string& text,
45                           int init_toggle, int target_menu, int id, int key);
46
47 public:
48   MenuItem(MenuItemKind kind, int id = -1);
49
50   void set_help(const std::string& help_text);
51
52   void change_text (const std::string& text);
53   void change_input(const std::string& text);
54
55   std::string get_input_with_symbol(bool active_item);   // returns the text with an input symbol
56
57 public:
58   MenuItemKind kind;
59   int id;   // item id
60   bool toggled;
61   std::string text;
62   std::string input;
63   std::string help;
64
65   std::vector<std::string> list; // list of values for a STRINGSELECT item
66   size_t selected; // currently selected item
67
68   int target_menu;
69
70 private:
71   /// keyboard key or joystick button
72   bool input_flickering;
73
74 private:
75   MenuItem(const MenuItem&);
76   MenuItem& operator=(const MenuItem&);
77 };
78
79 #endif
80
81 /* EOF */