-
-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathtextlabels.hpp
More file actions
119 lines (89 loc) · 3.98 KB
/
textlabels.hpp
File metadata and controls
119 lines (89 loc) · 3.98 KB
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
/*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v. 2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at http://mozilla.org/MPL/2.0/.
*
* The original code is copyright (c) 2022, open.mp team and contributors.
*/
#pragma once
#include <component.hpp>
#include <player.hpp>
#include <types.hpp>
#include <values.hpp>
struct IVehicle;
/// Text label attachment data
struct TextLabelAttachmentData
{
int playerID = INVALID_PLAYER_ID;
int vehicleID = INVALID_VEHICLE_ID;
};
/// Text label base interface
struct ITextLabelBase : public IExtensible, public IEntity
{
/// Set the text label's text
virtual void setText(StringView text) = 0;
/// Get the text label's text
virtual StringView getText() const = 0;
/// Set the text label's colour
virtual void setColour(Colour colour) = 0;
/// Get the text label's colour
virtual Colour getColour() const = 0;
/// Set the text label's draw distance
virtual void setDrawDistance(float dist) = 0;
/// Get the text label's draw distance
virtual float getDrawDistance() = 0;
/// Attach the text label to a player with an offset
virtual void attachToPlayer(IPlayer& player, Vector3 offset) = 0;
/// Attach the text label to a vehicle with an offset
virtual void attachToVehicle(IVehicle& vehicle, Vector3 offset) = 0;
/// Get the text label's attachment data
virtual const TextLabelAttachmentData& getAttachmentData() const = 0;
/// Detach the text label from the player and set its position or offset
virtual void detachFromPlayer(Vector3 position) = 0;
/// Detach the text label from the vehicle and set its position or offset
virtual void detachFromVehicle(Vector3 position) = 0;
// Set the text label's los check.
virtual void setTestLOS(bool status) = 0;
// Get the text label's los check status.
virtual bool getTestLOS() const = 0;
// Used to update both colour and text with one single network packet being sent.
virtual void setColourAndText(Colour colour, StringView text) = 0;
};
/// A global text label
struct ITextLabel : public ITextLabelBase
{
/// Checks if player has the text label streamed in for themselves
virtual bool isStreamedInForPlayer(const IPlayer& player) const = 0;
/// Streams in the text label for a specific player
virtual void streamInForPlayer(IPlayer& player) = 0;
/// Streams out the text label for a specific player
virtual void streamOutForPlayer(IPlayer& player) = 0;
};
/// A player text label
struct IPlayerTextLabel : public ITextLabelBase
{
};
static const UID TextLabelsComponent_UID = UID(0xa0c57ea80a009742);
/// The text label component which is a global text label pool
struct ITextLabelsComponent : public IPoolComponent<ITextLabel>
{
PROVIDE_UID(TextLabelsComponent_UID);
/// Create a text label
virtual ITextLabel* create(StringView text, Colour colour, Vector3 pos, float drawDist, int vw, bool los) = 0;
/// Create a text label and attach it to a player
virtual ITextLabel* create(StringView text, Colour colour, Vector3 pos, float drawDist, int vw, bool los, IPlayer& attach) = 0;
/// Create a text label and attach it to a vehicle
virtual ITextLabel* create(StringView text, Colour colour, Vector3 pos, float drawDist, int vw, bool los, IVehicle& attach) = 0;
};
static const UID PlayerTextLabelData_UID = UID(0xb9e2bd0dc5148c3c);
/// The text label player data which is a player text label pool
struct IPlayerTextLabelData : public IExtension, public IPool<IPlayerTextLabel>
{
PROVIDE_EXT_UID(PlayerTextLabelData_UID);
/// Create a player text label
virtual IPlayerTextLabel* create(StringView text, Colour colour, Vector3 pos, float drawDist, bool los) = 0;
/// Create a player text label and attach it to a player
virtual IPlayerTextLabel* create(StringView text, Colour colour, Vector3 pos, float drawDist, bool los, IPlayer& attach) = 0;
/// Create a player text label and attach it to a vehicle
virtual IPlayerTextLabel* create(StringView text, Colour colour, Vector3 pos, float drawDist, bool los, IVehicle& attach) = 0;
};