1 /*
2  * Copyright 2014 Peter Olsson
3  *
4  * This file is part of Brum Brum Rally.
5  *
6  * Brum Brum Rally is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Brum Brum Rally 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.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef SETTINGS_H
21 #define SETTINGS_H
22 
23 #include "SDL.h"
24 #include <map>
25 #include <string>
26 #include <vector>
27 #include <istream>
28 #include <ostream>
29 
30 namespace Settings
31 {
32 	struct Graphics
33 	{
34 		Graphics();
35 		int scaler;
36 		int fullscreen;
37 		int fullscreenWidth;
38 		int fullscreenHeight;
39 		int stretch;
40 		int keepAspectRatio;
41 		std::string pointer;
42 		int scalePointer;
43 
44 		void save(std::ostream&);
45 		void load(std::istream&);
46 	};
47 
48 	struct Players
49 	{
50 		Players();
51 		std::string humanNames[8];
52 		std::string computerNames[8];
53 		int computerDifficulties[8];
54 
55 		void save(std::ostream&);
56 		void load(std::istream&);
57 	};
58 
59 	struct Network
60 	{
61 		Network();
62 		int players;
63 		int network;
64 		std::string name;
65 		int maxPlayers;
66 		int maxPlayersPerClient;
67 		int computerPlayers;
68 		int computerDifficulty;
69 		int laps;
70 		int tracks;
71 		int collisions;
72 		bool tournament;
73 
74 		std::vector<Uint16> internetPorts;
75 		std::vector<Uint16> lanPorts;
76 		std::string server;
77 
78 		unsigned maxConnections;
79 		int chatFont;
80 		unsigned maxChatMessages;
81 		int chatMessageDuration;
82 
83 		void save(std::ostream&);
84 		void load(std::istream&);
85 	};
86 
87 	struct Tracks
88 	{
89 		Tracks();
90 		int minLength;
91 		int maxLength;
92 		int minWidth;
93 		int maxWidth;
94 		int minHeight;
95 		int maxHeight;
96 		int minCorners;
97 		int maxCorners;
98 		int minLongestStraighaway;
99 		int maxLongestStraighaway;
100 		int minLongestCornerSeries;
101 		int maxLongestCornerSeries;
102 
103 		std::map<std::string, int> tilesets;
104 
105 		void save(std::ostream&);
106 		void load(std::istream&);
107 	};
108 
109 	struct Race
110 	{
111 		Race();
112 		int humanPlayers;
113 		int computerPlayers;
114 		int laps;
115 		int tracks;
116 		int collisions;
117 		int difficulty;
118 		bool tournament;
119 
120 		void save(std::ostream&);
121 		void load(std::istream&);
122 	};
123 
124 	struct TimeTrial
125 	{
126 		TimeTrial();
127 		std::string name;
128 		int car;
129 		int remember;
130 		int showDriverGhost;
131 		int showBestGhost;
132 		int laps;
133 
134 		void save(std::ostream&);
135 		void load(std::istream&);
136 	};
137 
138 	extern Graphics graphics;
139 	extern Players players;
140 	extern Network network;
141 	extern Tracks tracks;
142 	extern Race race;
143 	extern TimeTrial timetrial;
144 
145 	void save(std::ostream&);
146 	void load(std::istream&);
147 }
148 
149 const int MIN_TRACK_LENGTH = 6;
150 const int MAX_TRACK_LENGTH = 70;
151 const int MIN_TRACK_WIDTH = 2;
152 const int MAX_TRACK_WIDTH = 10;
153 const int MIN_TRACK_HEIGHT = 2;
154 const int MAX_TRACK_HEIGHT = 7;
155 const int MIN_TRACK_CORNERS = 0;
156 const int MAX_TRACK_CORNERS = 100;
157 const int MIN_LONGEST_STRAIGHTAWAY = 1;
158 const int MAX_LONGEST_STRAIGHTAWAY = 8;
159 const int MIN_LONGEST_CORNER_SERIES = 1;
160 const int MAX_LONGEST_CORNER_SERIES = 70;
161 
162 const int DEFAULT_LAN_PORTS_FIRST = 6300;
163 const int DEFAULT_LAN_PORTS_LAST  = 6302;
164 
165 #endif
166