File: screen_overlay.h

package info (click to toggle)
scummvm 2.7.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 363,784 kB
  • sloc: cpp: 3,622,060; asm: 27,410; python: 10,528; sh: 10,241; xml: 6,752; java: 5,579; perl: 2,570; yacc: 1,635; javascript: 1,016; lex: 539; makefile: 398; ansic: 378; awk: 275; objc: 82; sed: 11; php: 1
file content (129 lines) | stat: -rw-r--r-- 4,006 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

 // ScreenOverlay is a simple sprite container with no advanced functions.
// May contain owned bitmap or reference persistent sprite's id, similar to how
// other game objects do that.
// May logically exist either on UI or room layer.

#ifndef AGS_ENGINE_AC_SCREEN_OVERLAY_H
#define AGS_ENGINE_AC_SCREEN_OVERLAY_H

#include "ags/lib/std/memory.h"
#include "ags/shared/core/types.h"

namespace AGS3 {

// Forward declaration
namespace AGS {
namespace Shared {
class Bitmap;
class Stream;
} // namespace Shared
} // namespace AGS

namespace AGS {
namespace Engine {
class IDriverDependantBitmap;
} // namespace Engine
} // namespace AGS

using namespace AGS; // FIXME later

enum OverlayFlags {
	kOver_AlphaChannel = 0x0001,
	kOver_PositionAtRoomXY = 0x0002, // room-relative position, may be in ui
	kOver_RoomLayer = 0x0004,        // work in room layer (as opposed to UI)
	kOver_SpriteReference = 0x0008   // reference persistent sprite
};

struct ScreenOverlay {
	// Texture
	Engine::IDriverDependantBitmap *ddb = nullptr;
	int type = 0, timeout = 0;
	// Note that x,y are overlay's properties, that define its position in script;
	// but real drawn position is x + offsetX, y + offsetY;
	int x = 0, y = 0;
	// Border/padding offset for the tiled text windows
	int offsetX = 0, offsetY = 0;
	// Width and height to stretch the texture to
	int scaleWidth = 0, scaleHeight = 0;
	int bgSpeechForChar = -1;
	int associatedOverlayHandle = 0; // script obj handle
	int zorder = INT_MIN;
	int transparency = 0;

	bool HasAlphaChannel() const {
		return (_flags & kOver_AlphaChannel) != 0;
	}
	bool IsSpriteReference() const {
		return (_flags & kOver_SpriteReference) != 0;
	}
	bool IsRoomRelative() const {
		return (_flags & kOver_PositionAtRoomXY) != 0;
	}
	bool IsRoomLayer() const {
		return (_flags & kOver_RoomLayer) != 0;
	}
	void SetAlphaChannel(bool on) {
		on ? _flags |= kOver_AlphaChannel : _flags &= ~kOver_AlphaChannel;
	}
	void SetRoomRelative(bool on) {
		on ? _flags |= kOver_PositionAtRoomXY : _flags &= ~kOver_PositionAtRoomXY;
	}
	void SetRoomLayer(bool on) {
		on ? _flags |= (kOver_RoomLayer | kOver_PositionAtRoomXY) :
			_flags &= ~(kOver_RoomLayer | kOver_PositionAtRoomXY);
	}
	// Gets actual overlay's image, whether owned by overlay or by a sprite reference
	Shared::Bitmap *GetImage() const;
	// Get sprite reference id, or -1 if none set
	int GetSpriteNum() const {
		return _sprnum;
	}
	void SetImage(Shared::Bitmap *pic, int offx = 0, int offy = 0);
	void SetSpriteNum(int sprnum, int offx = 0, int offy = 0);
	// Tells if Overlay has graphically changed recently
	bool HasChanged() const {
		return _hasChanged;
	}
	// Manually marks GUI as graphically changed
	void MarkChanged() {
		_hasChanged = true;
	}
	// Clears changed flag
	void ClearChanged() {
		_hasChanged = false;
	}

	void ReadFromFile(Shared::Stream *in, bool &has_bitmap, int32_t cmp_ver);
	void WriteToFile(Shared::Stream *out) const;

private:
	int _flags = 0; // OverlayFlags
	bool _hasChanged = false;
	std::shared_ptr<Shared::Bitmap> _pic; // owned bitmap
	int _sprnum = -1; // sprite reference
};

} // namespace AGS3

#endif