1 /*
2 Copyright (C) 2007, 2010 - Bit-Blot
3 
4 This file is part of Aquaria.
5 
6 Aquaria is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10 
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 
15 See the GNU General Public License for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21 #ifndef USERSETTINGS_H
22 #define USERSETTINGS_H
23 
24 #include <string>
25 
26 const std::string userSettingsFilename = "usersettings.xml";
27 
28 #ifndef AQUARIA_USERSETTINGS_DATAONLY
29 
30 	#include "Base.h"
31 	#include "ActionMapper.h"
32 
33 #else
34 
35 	#include <string>
36 	#include <vector>
37 	#include <sstream>
38 
39 	class ActionInput
40 	{
41 	public:
toString()42 		std::string toString()
43 		{
44 			return input;
45 		}
fromString(const std::string & str)46 		void fromString(const std::string &str)
47 		{
48 			input = str;
49 		}
50 
51 		std::string name, input;
52 	};
53 
54 	class ActionSet
55 	{
56 	public:
clearActions()57 		void clearActions()
58 		{
59 			inputSet.clear();
60 		}
addActionInput(const std::string & name)61 		ActionInput* addActionInput(const std::string &name)
62 		{
63 			ActionInput newActionInput;
64 			newActionInput.name = name;
65 			inputSet.push_back(newActionInput);
66 			return &inputSet[inputSet.size()-1];
67 		}
68 		std::vector<ActionInput> inputSet;
69 	};
70 
71 #endif
72 
73 // MAKE SURE to update this when changing the user settings
74 const int VERSION_USERSETTINGS	= 1;
75 
76 class UserSettings
77 {
78 public:
79 	struct System
80 	{
SystemSystem81 		System() { debugLogOn = 0; devModeOn = 0; allowDangerousScriptFunctions = 0; }
82 		int debugLogOn;
83 		std::string locale;
84 		int devModeOn;
85 		int allowDangerousScriptFunctions;
86 	} system;
87 
88 	struct Audio
89 	{
AudioAudio90 		Audio() { micOn = 0; octave=0; musvol=voxvol=sfxvol=1.0; subtitles=false; prebuffer=false;}
91 		int micOn;
92 		int octave;
93 		float voxvol, sfxvol, musvol;
94 		int subtitles;
95 		std::string deviceName;
96 		int prebuffer;
97 	} audio;
98 
99 	struct Video
100 	{
VideoVideo101 		Video() {
102 			numParticles = 2048;
103 			parallaxOn0 = parallaxOn1 = parallaxOn2 = 1;
104 			saveSlotScreens = 1;
105 			blur = 1;
106 			noteEffects = 0;
107 			fpsSmoothing = 30;
108 			resx = 800;
109 			resy = 600;
110 			full = 1;
111 			fbuffer = 1;
112 			darkfbuffer = 1;
113 			bits = 32;
114 			vsync = 1;
115 			darkbuffersize = 256;
116 			displaylists = 0;
117 			worldMapRevealMethod = 0;
118 		}
119 		int blur;
120 		int noteEffects;
121 		int fpsSmoothing;
122 		int resx, resy, full, fbuffer, bits, vsync, darkfbuffer, darkbuffersize;
123 		int saveSlotScreens;
124 		int parallaxOn0, parallaxOn1, parallaxOn2;
125 		int numParticles;
126 		int displaylists;
127 		int worldMapRevealMethod;
128 	} video;
129 
130 	struct Control
131 	{
ControlControl132 		Control() {
133 			toolTipsOn = 1;
134 			autoAim = 1;
135 			targeting = 1;
136 			joyCursorSpeed = 4.0;
137 			flipInputButtons = 0;
138 			s1ax = 0;
139 			s1ay = 0;
140 			s2ax = 0;
141 			s2ay = 0;
142 			s1dead = 0.3;
143 			s2dead = 0.3;
144 			joystickEnabled = 0;
145 		}
146 		int joystickEnabled;
147 		int autoAim;
148 		int targeting;
149 		float joyCursorSpeed;
150 		int flipInputButtons;
151 		ActionSet actionSet;
152 		int s1ax, s1ay, s2ax, s2ay;
153 		float s1dead, s2dead;
154 		int toolTipsOn;
155 	} control;
156 
157 	struct Demo
158 	{
DemoDemo159 		Demo() { warpKeys=0; intro=0; shortLogos=0; }
160 		int warpKeys;
161 		int intro;
162 		int shortLogos;
163 	} demo;
164 
165 	struct Data
166 	{
DataData167 		Data() { savePage=0; saveSlot=0; }
168 		int savePage;
169 		int saveSlot;
170 	} data;
171 
172 	struct Version
173 	{
VersionVersion174 		Version() { settingsVersion=1; }
175 		int settingsVersion;
176 	} version;
177 
178 	struct Network
179 	{
180 		std::string masterServer;
181 	} network;
182 
183 	void loadDefaults(bool doApply=true);
184 	void load(bool doApply=true, const std::string &overrideFile="");
185 	void save();
186 	void apply();
187 };
188 
189 #endif
190