Dragonfly  4.3
A text-based game engine
Config.h
1 //
2 // Config.h - Global configuration parameters for Dragonfly
3 //
4 
5 #ifndef __CONFIG_H__
6 #define __CONFIG_H__
7 
8 // System includes.
9 #include <string>
10 
11 // Engine includes.
12 #include "Color.h"
13 
14 namespace df {
15 
16 class Config {
17 
18  private:
19  Config(); ///< Private since a singleton.
20  Config(Config const&); ///< Don't allow copy.
21  void operator=(Config const&); ///< Don't allow assignment.
22  std::string m_config; ///< Aggregate string from config file.
23  int m_window_horizontal_pixels;///< Horizontal pixels in window.
24  int m_window_vertical_pixels; ///< Vertical pixels in window.
25  int m_window_horizontal_chars; ///< Horizontal ASCII spaces in window.
26  int m_window_vertical_chars; ///< Vertical ASCII spaces in window.
27  int m_window_style; ///< Style of window titlebar.
28  enum Color m_window_background_color; ///< Window background color.
29  int m_frame_time; ///< Target time for 1 game loop (in mlsecs).
30  float m_font_scale; ///< Font scale multiplier.
31  std::string m_window_title; ///< Title of window.
32  bool m_show_mouse; ///< True if should show mouse cursor.
33  bool m_headless; ///< True if run without graphics or input.
34  std::string m_font_file; ///< Filename for graphics fonts.
35  std::string m_logfile; ///< Filename for dragonfly log.
36  int m_random_seed; ///< Seed for random number generation.
37 
38  public:
39  /// Get the singleton instance of the Config.
40  static Config &getInstance();
41 
42  /// Get attributes.
43  std::string getConfig() const;
44  int getWindowHorizontalPixels() const;
45  int getWindowVerticalPixels() const;
46  int getWindowHorizontalChars() const;
47  int getWindowVerticalChars() const;
48  enum Color getWindowBackgroundColor() const;
49  int getWindowStyle() const;
50  int getFrameTime() const;
51  float getFontScale() const;
52  std::string getWindowTitle() const;
53  bool getShowMouse() const;
54  bool getHeadless() const;
55  std::string getFontFile() const;
56  std::string getLogFile() const;
57  int getRandomSeed() const;
58 
59  /// Match key:value pair in global configuration, returning value.
60  /// Return empty string if no match.
61  std::string match(std::string find) const;
62 
63  /// Set attributes.
64  void setConfig(std::string config);
65  void setWindowHorizontalPixels(int window_horizontal_pixels);
66  void setWindowVerticalPixels(int window_vertical_pixels);
67  void setWindowHorizontalChars(int window_horizontal_chars);
68  void setWindowVerticalChars(int window_vertical_chars);
69  void setWindowBackgroundColor(enum Color window_background_color);
70  void setWindowStyle(int window_style);
71  void setFrameTime(int frame_time);
72  void setFontScale(float font_scale);
73  void setWindowTitle(std::string window_title);
74  void setHeadless(bool headless=true);
75  void setShowMouse(bool show_mouse=true);
76  void setFontFile(std::string font_file);
77  void setLogFile(std::string logfile);
78  void setRandomSeed(int random_seed);
79 
80  // Write all parameters to logfile.
81  void writeToLog() const;
82 };
83 
84 } // end of namespace df
85 #endif // __CONFIG_H__
float m_font_scale
Font scale multiplier.
Definition: Config.h:30
int m_random_seed
Seed for random number generation.
Definition: Config.h:36
int m_window_vertical_pixels
Vertical pixels in window.
Definition: Config.h:24
void operator=(Config const &)
Don&#39;t allow assignment.
int m_window_vertical_chars
Vertical ASCII spaces in window.
Definition: Config.h:26
bool m_headless
True if run without graphics or input.
Definition: Config.h:33
A 2-d bounding box.
Definition: Box.h:10
std::string m_config
Aggregate string from config file.
Definition: Config.h:22
bool m_show_mouse
True if should show mouse cursor.
Definition: Config.h:32
int m_window_horizontal_pixels
Horizontal pixels in window.
Definition: Config.h:23
int m_window_style
Style of window titlebar.
Definition: Config.h:27
std::string getConfig() const
Get attributes.
void setConfig(std::string config)
Set attributes.
Definition: Config.h:16
enum Color m_window_background_color
Window background color.
Definition: Config.h:28
std::string match(std::string find) const
Match key:value pair in global configuration, returning value.
Color
Colors Dragonfly recognizes.
Definition: Color.h:11
std::string m_window_title
Title of window.
Definition: Config.h:31
std::string m_font_file
Filename for graphics fonts.
Definition: Config.h:34
int m_window_horizontal_chars
Horizontal ASCII spaces in window.
Definition: Config.h:25
static Config & getInstance()
Get the singleton instance of the Config.
Config()
Private since a singleton.
int m_frame_time
Target time for 1 game loop (in mlsecs).
Definition: Config.h:29
std::string m_logfile
Filename for dragonfly log.
Definition: Config.h:35