File: Config.h

package info (click to toggle)
pinball 0.3.20201218-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 8,452 kB
  • sloc: cpp: 15,230; makefile: 840; sh: 381; xml: 24
file content (123 lines) | stat: -rw-r--r-- 4,362 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//#ident "$Id: Config.h,v 1.17 2003/06/11 13:25:49 rzr Exp $"
/***************************************************************************
                          Config.h  -  description
                             -------------------
    begin                : Wed Jan 26 2000
    copyright            : (C) 2000 by Henrik Enqvist
    email                : henqvist@excite.com
 ***************************************************************************/

#ifndef CONFIG_H
#define CONFIG_H

#include <string>
#include <cstring>
#include <map>

#include "EMath.h"
#include "Keyboard.h"

#ifndef PRIVATE_H
#error "Must include Private.h before Config.h"
#endif

#if EM_USE_SDL
//#include <GL/gl.h>
#include <SDL_opengl.h> //!+-rzr: better portability
#define EM_LINEAR GL_LINEAR
#define EM_NEAREST GL_NEAREST
#else
#define EM_LINEAR 0
#define EM_NEAREST 1
#endif

/** */
class Config {
 protected:
  Config();
 public:
  ~Config();
  static Config * getInstance();
  void loadArgs(int & argc, char* argv[]);
  inline const int getWidth() { return m_iWidth; };
  inline const int getHeight() { return m_iHeight; };
  inline const int getWidthDiv2() { return m_iWidthDiv2; };
  inline const int getHeightDiv2() { return m_iHeightDiv2; };
  inline float getRatio() const { return m_fRatio; };
  inline const int getBpp() { return m_iBpp; };
  inline const int getGLFilter() { return m_iGLFilter; };
  inline const int getView() { return m_iView; };
  inline const float getBrightness() { return m_fBrightness; };
  inline const bool useFullScreen() { return m_bFullScreen; };
  inline const int getSound() { return m_iSound; };
  inline const int getMusic() { return m_iMusic; };
  inline const bool getFire() { return m_bFire; };
  inline const bool useExternGL() { return m_bExternGL; };
  inline const bool useLights() { return m_bLights; };
  void setSize(int const w, int const h);
  inline void setBpp(int const bpp) { m_iBpp = bpp; };
  inline void setGLFilter(int const filter) { m_iGLFilter = filter; };
  inline void setView(int const view) { m_iView = view; };
  inline void setShowFPS(bool const fps) { m_bShowFPS = fps; };
  inline bool getShowFPS() { return m_bShowFPS; };
  /** This will NOT set the engine to full screen. You have to do
   * that manually. It only updates the config class, (ie, reading writing
	 * to config file). */
  inline void setFullScreen(bool const f) { m_bFullScreen = f; };
  /** This will NOT set the volume. You have to do that manually. 
	 * It only updates the config class, (ie, reading writing
	 * to config file). */
  inline void setSound(int const s) { m_iSound = EM_MIN( EM_MAX(s, 0), 8); };
  inline void setMusic(int const m) { m_iMusic = EM_MIN( EM_MAX(m, 0), 8); };
  inline void setFire(bool const f) { m_bFire = f; };
  inline void setLights(bool const l) { m_bLights = l; };
  /** This will NOT set the brightness in the engine. You
   * have to do that manually. */
  inline void setBrightness(float const b) { m_fBrightness = b; };
  /** Gets the key code from a key identifier. (e.g. "leftnudge" -> 306)*/
  EMKey getKey(string const & str);
  /** Gets the common name from a key code. (e.g. 306 -> "left ctrl") */
  char const *  const getKeyCommonName(EMKey);
  void setKey(string const & str, EMKey key);
  void setDataDir(const char * ch);
  void setSubDir(const char * ch);
  inline const char * getDataDir() { return m_sDataDir.c_str(); };
  inline const char * getDataSubDir() { return m_sDataSubDir.c_str(); };
  inline const char * getExeDir() { return m_sExeDir.c_str(); };
  void saveConfig();
  void loadConfig();
  void setDefault();
  /// set RELATIVE path according to current work directory of exec
  void setPaths(char const * const argv0);  //!+rzr

 private:
  int m_iWidth;
  int m_iHeight;
  int m_iWidthDiv2;
  int m_iHeightDiv2;
  float m_fRatio;
  int m_iBpp;
  int m_iGLFilter;
  int m_iView;
  bool m_bFire;
  bool m_bLights;
  bool m_bExternGL;
  int m_iSound;
  int m_iMusic;
  bool m_bShowFPS;
  bool m_bFullScreen;
  /// executable dir (maindir on w32)
  string m_sExeDir;
  string m_sDataDir;
  string m_sSubDir;
  string m_sDataSubDir;
  float m_fBrightness;
  static Config* p_Instance;
  /// prototypes of Static Modules
  map<string, EMKey> m_hKey;

  // Keep the high scores for the current table
  multimap<int, string> m_mapHighScores;
};

#endif // CONFIG_H