22 #ifndef ALCACHOFA_COMMON_H 23 #define ALCACHOFA_COMMON_H 25 #include "common/rect.h" 26 #include "common/serializer.h" 27 #include "common/stream.h" 28 #include "common/str-enc.h" 29 #include "common/stack.h" 30 #include "math/vector2d.h" 31 #include "math/vector3d.h" 35 enum class CursorType {
44 enum class Direction {
60 enum class MainCharacterKind {
66 enum class EasingType {
73 constexpr
const int32 kDirectionCount = 4;
74 constexpr
const int32 kFullDirectionCount = 8;
75 constexpr
const int8 kOrderCount = 70;
76 constexpr
const int8 kForegroundOrderCount = 10;
81 static constexpr
const Color kWhite = { 255, 255, 255, 255 };
82 static constexpr
const Color kBlack = { 0, 0, 0, 255 };
83 static constexpr
const Color kClear = { 0, 0, 0, 0 };
84 static constexpr
const Color kDebugRed = { 250, 0, 0, 70 };
85 static constexpr
const Color kDebugGreen = { 0, 255, 0, 85 };
86 static constexpr
const Color kDebugBlue = { 0, 0, 255, 110 };
87 static constexpr
const Color kDebugLightBlue = { 80, 80, 255, 190 };
97 inline bool isReleased()
const {
return _counter == 0; }
98 inline uint counter()
const {
return _counter; }
103 const char *
const _name;
117 inline bool isReleased()
const {
return _semaphore ==
nullptr; }
119 void debug(
const char *action);
121 const char *_name =
"<uninitialized>";
125 bool isPowerOfTwo(int16 x);
127 float ease(
float t, EasingType type);
131 Common::CodePage from = Common::CodePage::kISO8859_1,
132 Common::CodePage to = Common::CodePage::kUtf8);
134 Math::Vector3d as3D(
const Math::Vector2d &v);
136 Math::Vector2d as2D(
const Math::Vector3d &v);
145 Direction intToDirection(int32 value);
150 auto size = array.
size();
151 serializer.syncAsUint32LE(size);
153 serializer.syncArray(array.
data(), size, serializeFunction);
157 inline void syncStack(
161 Common::Serializer::Version minVersion = 0) {
165 auto size = stack.size();
166 serializer.syncAsUint32LE(size);
167 if (serializer.isLoading()) {
168 for (uint i = 0; i < size; i++) {
170 serializeFunction(serializer, value);
174 for (uint i = 0; i < size; i++)
175 serializeFunction(serializer, stack[i]);
182 int32 intValue =
static_cast<int32
>(enumValue);
183 serializer.syncAsSint32LE(intValue);
184 enumValue =
static_cast<T
>(intValue);
200 _fileIndex = UINT32_MAX,
201 _position = UINT32_MAX,
212 , _fileIndex(fileIndex)
213 , _position(position)
216 inline bool isValid()
const {
217 return !_path.empty() || _fileIndex != UINT32_MAX;
220 inline bool isEmbedded()
const {
221 return _fileIndex != UINT32_MAX;
227 #endif // ALCACHOFA_COMMON_H Definition: alcachofa.h:45
const T * data() const
Definition: array.h:208
Definition: display_client.h:58
Definition: serializer.h:79
void debug(MSVC_PRINTF const char *s,...) GCC_PRINTF(1
References a game file either as path or as embedded byte range.
Definition: common.h:197
size_type size() const
Definition: array.h:316
Version getVersion() const
Definition: serializer.h:172
void resize(size_type newSize)
Definition: array.h:412
This fake semaphore does not work in multi-threaded scenarios It is used as a safer option for a simp...
Definition: common.h:93