1 /*
2  Copyright (c) 2013 yvt
3 
4  This file is part of OpenSpades.
5 
6  OpenSpades 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  OpenSpades 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 OpenSpades.  If not, see <http://www.gnu.org/licenses/>.
18 
19  */
20 
21 #pragma once
22 
23 #include <functional>
24 #include <map>
25 #include <vector>
26 
27 #include <Core/Math.h>
28 #include <Core/Mutex.h>
29 #include <Core/RefCountedObject.h>
30 #include <ScriptBindings/ScriptManager.h>
31 
32 // scriptarray.h must be included after ScriptManager.h or it won't be able to
33 // find angelscript.h
34 #include <AngelScript/addons/scriptarray.h>
35 
36 namespace spades {
37 	class Serveritem;
38 	class PackageUpdateManager;
39 	namespace gui {
40 		class StartupScreen;
41 		class StartupScreenHelper : public RefCountedObject {
42 			friend class StartupScreen;
43 			StartupScreen *scr;
44 			std::vector<IntVector3> modes;
45 			struct ReportLine {
46 				std::string text;
47 				Vector4 color;
48 			};
49 			std::vector<ReportLine> reportLines;
50 			std::string report;
51 			void AddReport(const std::string &text = std::string(),
52 			               Vector4 color = Vector4::Make(1.f, 1.f, 1.f, 1.f));
53 
54 			struct LocaleInfo {
55 				std::string name;
56 				std::string descriptionNative;
57 				std::string descriptionEnglish;
58 			};
59 			std::vector<LocaleInfo> locales;
60 
61 			std::multimap<std::string, std::function<std::string(std::string)>> incapableConfigs;
62 
63 			bool shaderHighCapable;
64 			bool postFilterHighCapable;
65 			bool particleHighCapable;
66 			bool openGLCapable;
67 
68 		protected:
69 			~StartupScreenHelper();
70 
71 		public:
72 			StartupScreenHelper();
BindStartupScreen(StartupScreen * scr)73 			void BindStartupScreen(StartupScreen *scr) { this->scr = scr; }
74 			void StartupScreenDestroyed();
75 
76 			void ExamineSystem();
77 
78 			int GetNumVideoModes();
79 			int GetVideoModeWidth(int index);
80 			int GetVideoModeHeight(int index);
81 
82 			int GetNumReportLines();
GetReport()83 			std::string GetReport() { return report; }
84 			std::string GetReportLineText(int line);
85 			Vector4 GetReportLineColor(int line);
86 
87 			int GetNumLocales();
88 			std::string GetLocale(int index);
89 			std::string GetLocaleDescriptionNative(int index);
90 			std::string GetLocaleDescriptionEnglish(int index);
91 
92 			std::string CheckConfigCapability(const std::string &cfg, const std::string &value);
93 
94 			PackageUpdateManager& GetPackageUpdateManager();
95 			bool OpenUpdateInfoURL();
96 
97 			/** Checks each config value and modifies it if its value isn't feasible */
98 			void FixConfigs();
99 
100 			std::string GetOperatingSystemType();
101 			bool BrowseUserDirectory();
102 
103 			void Start();
104 		};
105 	}
106 }
107