NasNas
An intuitive and beginner friendly 2D game framework for C++
Config.hpp
1 
6 #pragma once
7 
8 #include <string>
9 #include <unordered_map>
10 
11 #include <SFML/System/Vector2.hpp>
12 #include <SFML/Window/VideoMode.hpp>
13 #include <SFML/Window/WindowStyle.hpp>
14 
15 #include <NasNas/core/data/Utils.hpp>
16 #include <NasNas/core/AppAccess.hpp>
17 
18 namespace ns {
19  struct AppConfig {
20  std::string title = "NasNas app";
21  sf::Vector2u resolution = {720, 480};
22  float scale = 1.f;
23  int frame_rate = 60;
24  int update_rate = 60;
25  bool vertical_sync = false;
26  int window_style = sf::Style::Default;
27  unsigned antialiasing_level = 0;
28  bool key_repeat = false;
29  bool cursor_visible = true;
30  bool cursor_grabbed = false;
31 
32  auto getViewSize() const -> const sf::Vector2f&;
33  auto getViewRatio() const -> float;
34 
35  private: // private configs set by the App
36  friend App;
37  sf::VideoMode video_mode;
38  sf::Vector2f view_size;
39  float view_ratio = 1.f;
40  };
41 
42  class Settings : AppAccess<> {
43  friend App;
44  static AppConfig user_config;
45 
46  struct debug_info : public utils::bool_switch {
47  friend Settings;
48  debug_info(const debug_info&) = delete;
49  utils::bool_switch show_fps;
50  utils::bool_switch show_text;
51  utils::bool_switch show_bounds;
52  auto operator=(bool value) -> debug_info& override;
53  private:
54  debug_info();
55  unsigned int m_state;
56  };
57 
58  public:
59  static debug_info debug_mode;
60 
61  static void setConfig(AppConfig config);
62  static auto getConfig() -> const AppConfig&;
63 
64  class Modules {
65  public:
66  static const bool Core;
67  static const bool Reslib;
68  static const bool Ecs;
69  static const bool Tilemapping;
70  static const bool Ui;
71  };
72 
73  enum class Platform {
74  Windows,
75  Linux,
76  macOS,
77  Android,
78  iOS,
79  Other
80  };
81 
82  static const Platform platform;
83  };
84 
85 }
Definition: App.hpp:39