1 /* 2 * Copyright (c) 2000 Mark B. Allan. All rights reserved. 3 * 4 * "Chromium B.S.U." is free software; you can redistribute 5 * it and/or use it and/or modify it under the terms of the 6 * "Clarified Artistic License" 7 */ 8 #ifndef Config_h 9 #define Config_h 10 11 #include "compatibility.h" 12 13 #include <cstdio> 14 15 /** 16 * contains data obtained from config file. Singleton. 17 */ 18 //==================================================================== 19 class Config 20 { 21 public: 22 ~Config(); 23 24 static Config *init(); 25 static Config *instance(); 26 static void destroy(); 27 28 29 const char *getFileName(); 30 const char *getOldFileName(); 31 void readValues(FILE* file); 32 bool readFile(); 33 bool saveFile(); 34 35 36 void setScreenSize(int m); 37 void setScreenSize(int w, int h); 38 int approxScreenSize(); 39 screenW()40 int screenW() { return m_screenW; } screenH()41 int screenH() { return m_screenH; } screenA()42 float screenA() { return m_screenA; } screenFOV()43 float screenFOV() { return m_screenFOV; } screenNear()44 float screenNear() { return m_screenNear; } screenFar()45 float screenFar() { return m_screenFar; } screenBoundX()46 float screenBoundX() { return m_screenBound[0];} screenBoundY()47 float screenBoundY() { return m_screenBound[1];} zTrans()48 float zTrans() { return m_zTrans; } 49 fullScreen()50 bool fullScreen() { return m_full_screen; } blend()51 bool blend() { return m_blend_enabled;} texBorder()52 bool texBorder() { return m_tex_border; } audioEnabled()53 bool audioEnabled() { return m_audio_enabled;} swapStereo()54 bool swapStereo() { return m_swap_stereo; } autoSpeed()55 bool autoSpeed() { return m_auto_speed; } showFPS()56 bool showFPS() { return m_show_fps; } trueColor()57 bool trueColor() { return m_true_color; } usePlayList()58 bool usePlayList() { return m_use_playList; } 59 #ifdef USE_SDL_CDROM useCDROM()60 bool useCDROM() { return m_use_cdrom; } 61 #endif // USE_SDL_CDROM debug()62 bool debug() { return m_debug; } setFullScreen(bool s)63 void setFullScreen(bool s) { m_full_screen = s; } setBlend(bool s)64 void setBlend(bool s) { m_blend_enabled = s;} setTexBorder(bool s)65 void setTexBorder(bool s) { m_tex_border = s; } setAudio(bool s)66 void setAudio(bool s) { m_audio_enabled = s;} setSwapStereo(bool s)67 void setSwapStereo(bool s) { m_swap_stereo = s; } setAutoSpeed(bool s)68 void setAutoSpeed(bool s) { m_auto_speed = s; } setShowFPS(bool s)69 void setShowFPS(bool s) { m_show_fps = s; } setTrueColor(bool s)70 void setTrueColor(bool s) { m_true_color = s; } setUsePlayList(bool s)71 void setUsePlayList(bool s) { m_use_playList = s; } 72 #ifdef USE_SDL_CDROM setUseCDROM(bool s)73 void setUseCDROM(bool s) { m_use_cdrom = s; } 74 #endif // USE_SDL_CDROM setDebug(bool s)75 void setDebug(bool s) { m_debug = s; } 76 77 #ifdef USE_SDL_CDROM CDROMDevice()78 int CDROMDevice() { return m_cdromDevice; } CDROMCount()79 int CDROMCount() { return m_cdromCount; } setCDROMDevice(int i)80 void setCDROMDevice(int i) { m_cdromDevice = i; } setCDROMCount(int c)81 void setCDROMCount(int c) { m_cdromCount = c; } 82 #endif // USE_SDL_CDROM 83 gfxLevel()84 int gfxLevel() { return m_gfxLevel; } maxLevel()85 int maxLevel() { return m_maxLevel; } setGfxLevel(int a)86 void setGfxLevel(int a) { m_gfxLevel = a; if(m_gfxLevel < 0) m_gfxLevel = 0; if(m_gfxLevel > 2) m_gfxLevel = 2; } setMaxLevel(int a)87 void setMaxLevel(int a) { m_maxLevel = a; if(m_maxLevel > 10) m_maxLevel = 10; } 88 movementSpeed()89 float movementSpeed() { return m_movementSpeed; } gameSkillBase()90 float gameSkillBase() { return m_gameSkillBase; } viewGamma()91 float viewGamma() { return m_viewGamma; } volSound()92 float volSound() { return m_volSound; } volMusic()93 float volMusic() { return m_volMusic; } setMovementSpeed(float f)94 void setMovementSpeed(float f) { m_movementSpeed = f; if(m_movementSpeed < 0.01) m_movementSpeed = 0.01; if(m_movementSpeed > 0.1) m_movementSpeed = 0.1; } setGameSkillBase(float f)95 void setGameSkillBase(float f) { m_gameSkillBase = f; if(m_gameSkillBase > 0.9) m_gameSkillBase = 0.9; if(m_gameSkillBase < 0.2) m_gameSkillBase = 0.2;} setViewGamma(float f)96 void setViewGamma(float f) { m_viewGamma = f; } setVolSound(float f)97 void setVolSound(float f) { m_volSound = f; if(m_volSound < 0.0) m_volSound = 0.0; if(m_volSound > 1.0) m_volSound = 1.0; } setVolMusic(float f)98 void setVolMusic(float f) { m_volMusic = f; if(m_volMusic < 0.0) m_volMusic = 0.0; if(m_volMusic > 1.0) m_volMusic = 1.0; } 99 intSkill()100 int intSkill() { return (int)((m_gameSkillBase+0.05)*10.0); } 101 102 enum AudioType { AudioOpenAL, AudioSDL_Mixer, NumAudioTypes }; audioType()103 AudioType audioType() { return m_audioType; }; 104 105 enum TextType { TextGLC, TextFTGL, NumTextTypes }; textType()106 TextType textType() { return m_textType; }; 107 108 private: 109 int m_screenW; 110 int m_screenH; 111 float m_screenA; 112 float m_screenFOV; 113 float m_screenNear; 114 float m_screenFar; 115 bool m_full_screen; 116 float m_screenBound[2]; 117 float m_zTrans; 118 119 bool m_blend_enabled; 120 bool m_tex_border; 121 bool m_audio_enabled; 122 bool m_swap_stereo; 123 bool m_auto_speed; 124 bool m_show_fps; 125 bool m_true_color; 126 bool m_use_playList; 127 #ifdef USE_SDL_CDROM 128 bool m_use_cdrom; 129 #endif // USE_SDL_CDROM 130 bool m_debug; 131 132 int m_gfxLevel; 133 int m_maxLevel; 134 #ifdef USE_SDL_CDROM 135 int m_cdromDevice; 136 int m_cdromCount; 137 #endif // USE_SDL_CDROM 138 139 float m_movementSpeed; 140 float m_gameSkillBase; 141 float m_viewGamma; 142 float m_volSound; 143 float m_volMusic; 144 145 AudioType m_audioType; 146 147 TextType m_textType; 148 149 private: 150 static Config *m_instance; 151 152 Config(); 153 }; 154 155 #endif // Config_h 156