1 /*
2  * Copyright (C) 2006-2019 Christopho, Solarus - http://www.solarus-games.org
3  *
4  * Solarus is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Solarus is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /**
19  * \file Common.h
20  * \brief This header should be included by each class header file.
21  */
22 
23 #ifndef SOLARUS_COMMON_H
24 #define SOLARUS_COMMON_H
25 
26 #ifdef ANDROID
27 #include "solarus/core/AndroidConfig.h"
28 #else
29 #include "solarus/core/config.h"
30 #endif
31 
32 /**
33  * \cond doxygen_ignore
34  */
35 #define SOLARUS_STRINGIFY1(x) #x
36 #define SOLARUS_STRINGIFY(x) SOLARUS_STRINGIFY1(x)
37 /**
38  * \endcond
39  */
40 
41 /**
42  * \brief The Solarus version as a string.
43  *
44  * This string has the form "x.y.z" where x is the major version, y is the
45  * minor version and z is the patch version.
46  */
47 #define SOLARUS_VERSION SOLARUS_STRINGIFY(SOLARUS_MAJOR_VERSION) "." SOLARUS_STRINGIFY(SOLARUS_MINOR_VERSION) "." SOLARUS_STRINGIFY(SOLARUS_PATCH_VERSION)
48 
49 /**
50  * \brief The Solarus version as a string, without patch number.
51  *
52  * This string has the form "x.y" where x is the major version and y is the
53  * minor version.
54  */
55 #define SOLARUS_VERSION_WITHOUT_PATCH SOLARUS_STRINGIFY(SOLARUS_MAJOR_VERSION) "." SOLARUS_STRINGIFY(SOLARUS_MINOR_VERSION)
56 
57 // Windows specific.
58 /**
59  * \def SOLARUS_API
60  * \brief Windows DLL import/export specifications for the Solarus library symbols.
61  */
62 #ifndef SOLARUS_LIBRARY_EXPORT
63 #  ifdef solarus_EXPORTS  // Define automatically added by cmake.
64 #    define SOLARUS_LIBRARY_EXPORT 1
65 #  else
66 #    define SOLARUS_LIBRARY_EXPORT 0
67 #  endif
68 #else
69 #    define SOLARUS_LIBRARY_EXPORT 0
70 #endif
71 
72 #ifdef _WIN32
73 #  if SOLARUS_LIBRARY_EXPORT == 1
74 #    define SOLARUS_API __declspec(dllexport)
75 #  else
76 #    define SOLARUS_API __declspec(dllimport)
77 #  endif
78 
79 #  ifdef _MSC_VER
80 // TODO MSVC: fix these warnings instead of disabling them
81 #    pragma warning( disable : 4251 4275 4458 4514 4710 4820 4244 4800)
82 // 4251 needs to have dll-interface to be used by clients of class
83 // 4275 non dll-interface class 'Foo::Bar' used as base for dll-interface class 'Foo::Baz'
84 // 4458 declaration of 'foo' hides class member
85 // 4514 unreferenced inline function has been removed
86 // 4710 function not inlined
87 // 4820 padding added after data member
88 // 4244 'argument': conversion from 'foo' to 'bar', possible loss of data
89 // 4800 'int': forcing value to bool 'true' or 'false' (performance warning)
90 #  endif
91 
92 #else
93 #  define SOLARUS_API
94 #endif
95 
96 // Define the current platform constants on Apple Systems.
97 
98 /**
99  * \cond doxygen_ignore
100  * Define the current platform constants on Apple Systems.
101  */
102 #if defined(__APPLE__)
103 #  include "TargetConditionals.h"
104 #  if TARGET_OS_IPHONE == 1
105 #    define SOLARUS_IOS
106 // TARGET_OS_MAC is set to 1 on both IPhone, IPhone simulator and Mac OS.
107 #  elif TARGET_OS_MAC == 1
108 #    define SOLARUS_OSX
109 #  endif
110 #endif
111 /**
112  * \endcond
113  */
114 
115 /**
116  * \def SOLARUS_DEFAULT_QUEST
117  * \brief Path of the quest to run is none is specified at runtime.
118  */
119 #ifndef SOLARUS_DEFAULT_QUEST
120 // if no default quest was specified at compilation time,
121 // use the current directory
122 #  define SOLARUS_DEFAULT_QUEST "."
123 #endif
124 
125 /**
126  * \def SOLARUS_WRITE_DIR
127  * \brief Where savegames are stored, relative to the user base write directory.
128  */
129 #ifndef SOLARUS_WRITE_DIR
130 #  if defined(SOLARUS_OSX) || defined(SOLARUS_IOS)
131 #    define SOLARUS_WRITE_DIR "Solarus"
132 #  else
133 #    define SOLARUS_WRITE_DIR ".solarus"
134 #  endif
135 #endif
136 
137 // Game size.
138 
139 /**
140  * \def SOLARUS_DEFAULT_QUEST_WIDTH
141  * \brief Width of the quest screen in pixels if not set at runtime.
142  */
143 #ifndef SOLARUS_DEFAULT_QUEST_WIDTH
144 #  if defined(PANDORA)
145 #    define SOLARUS_DEFAULT_QUEST_WIDTH 400
146 #  else
147 #    define SOLARUS_DEFAULT_QUEST_WIDTH 320
148 #  endif
149 #endif
150 
151 /**
152  * \def SOLARUS_DEFAULT_QUEST_HEIGHT
153  * \brief Height of the quest screen in pixels if not set at runtime.
154  */
155 #ifndef SOLARUS_DEFAULT_QUEST_HEIGHT
156 #  define SOLARUS_DEFAULT_QUEST_HEIGHT 240
157 #endif
158 
159 #endif
160 
161