Debian Codegraph @

src/game/menu/trackselectionmenu.hpp

raw symbols SCIP
1 // This file is part of Dust Racing 2D.
2 // Copyright (C) 2012 Jussi Lind <[email protected]>
3 //
4 // Dust Racing 2D 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 // Dust Racing 2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Dust Racing 2D. If not, see <http://www.gnu.org/licenses/>.
15
16 #ifndef TRACKSELECTIONMENU_HPP
17 #define TRACKSELECTIONMENU_HPP
18
19 #include "surfacemenu.hpp"
20
21 class Track;
22 class TrackItem;
23 class Scene;
24 class MCSurface;
25
26 //! Allows the user to select a track to play.
27 class TrackSelectionMenu : public SurfaceMenu
28 {
29 public:
30 static std::string MenuId;
31
32 //! Constructor.
33 TrackSelectionMenu(int width, int height, Scene & scene);
34
35 //! Add a track to the list of selectable tracks.
36 void addTrack(std::shared_ptr<Track> track);
37
38 //! Returns the selected track or nullptr.
39 std::shared_ptr<Track> selectedTrack() const;
40
41 //! \reimp
42 virtual void left() override;
43
44 //! \reimp
45 virtual void right() override;
46
47 //! \reimp
48 virtual void up() override;
49
50 //! \reimp
51 virtual void down() override;
52
53 //! \reimp
54 virtual void exit() override;
55
56 //! \reimp
57 virtual void selectCurrentItem() override;
58
59 private:
60 std::shared_ptr<Track> m_selectedTrack;
61
62 Scene & m_scene;
63
64 int m_prevIndex = 0;
65 };
66
67 #endif // TRACKSELECTIONMENU_HPP