supertux
world_select.hpp
1 // SuperTux
2 // Copyright (C) 2021 A. Semphris <semphris@protonmail.com>
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_WORLDMAP_WORLD_SELECT_HPP
18 #define HEADER_SUPERTUX_WORLDMAP_WORLD_SELECT_HPP
19 
20 #include <memory>
21 
22 #include "supertux/screen.hpp"
23 #include "util/currenton.hpp"
24 #include "video/surface_ptr.hpp"
25 
26 namespace worldmap {
27 
28 class WorldMap;
29 
30 class WorldSelect final : public Screen,
31  public Currenton<WorldSelect>
32 {
33 private:
34  static const float s_torque;
35 
36 private:
37  class WMdata
38  {
39  public:
40  WMdata() = default;
41 
42  std::string filename = "";
43  std::string name = "";
44  bool unlocked = false;
45  SurfacePtr icon = nullptr;
46  };
47 
48 public:
49  WorldSelect(const std::string& current_world_filename);
50  ~WorldSelect() override;
51 
52  virtual void setup() override;
53  virtual void leave() override;
54 
55  virtual void draw(Compositor& compositor) override;
56  virtual void update(float dt_sec, const Controller& controller) override;
57  virtual IntegrationStatus get_status() const override;
58 
59 private:
60  bool m_enabled;
61  std::vector<WMdata> m_worlds;
62  int m_current_world;
63  int m_selected_world;
64  float m_angle;
65  SurfacePtr m_bkg;
66 
67 private:
68  WorldSelect(const WorldSelect&) = delete;
69  WorldSelect& operator=(const WorldSelect&) = delete;
70 };
71 
72 } // namespace worldmap
73 
74 #endif
75 
76 /* EOF */
Definition: controller.hpp:57
Abstract base class for code the MainLoop runs exclusively and full-screen.
Definition: screen.hpp:31
virtual void draw(Compositor &compositor) override
gets called once per frame.
Definition: world_select.cpp:163
virtual void update(float dt_sec, const Controller &controller) override
gets called for once (per logical) frame.
Definition: world_select.cpp:210
Definition: object_settings.hpp:32
A &#39;Currenton&#39; allows access to the currently active instance of a class via the static current() func...
Definition: currenton.hpp:30
virtual IntegrationStatus get_status() const override
Gives details about what the user is doing right now.
Definition: world_select.cpp:256
virtual void leave() override
gets called when the current screen is temporarily suspended
Definition: world_select.cpp:157
Definition: compositor.hpp:29
Definition: integration.hpp:26
virtual void setup() override
gets called before this screen gets activated (which is at least once before the first draw or update...
Definition: world_select.cpp:148
Definition: world_select.hpp:30