SourcePP
Several modern C++20 libraries for sanely parsing Valve's formats.
Toggle main menu visibility
Loading...
Searching...
No Matches
SHT.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <array>
4
#include <filesystem>
5
#include <span>
6
#include <vector>
7
8
#include <
sourcepp/Math.h
>
9
10
namespace
vtfpp
{
11
12
class
SHT
{
13
public
:
14
struct
Sequence
{
15
struct
Frame
{
16
struct
Bounds
{
17
float
x1
;
18
float
y1
;
19
float
x2
;
20
float
y2
;
21
};
22
23
float
duration
;
24
// A sprite frame can reference 1 or 4 images, depending on the version
25
std::array<Bounds, 4>
bounds
;
26
27
void
setAllBounds
(
Bounds
newBounds) {
28
this->bounds[0] = newBounds;
29
this->bounds[1] = newBounds;
30
this->bounds[2] = newBounds;
31
this->bounds[3] = newBounds;
32
}
33
};
34
35
uint32_t
id
;
36
bool
loop
;
37
std::vector<Frame>
frames
;
38
float
durationTotal
;
39
};
40
41
SHT
();
42
43
explicit
SHT
(std::span<const std::byte> shtData);
44
45
explicit
SHT
(
const
std::filesystem::path& shtPath);
46
47
[[nodiscard]]
explicit
operator
bool()
const
;
48
49
[[nodiscard]] uint32_t
getVersion
()
const
;
50
51
void
setVersion
(uint32_t v);
52
53
[[nodiscard]]
const
std::vector<Sequence>&
getSequences
()
const
;
54
55
[[nodiscard]] std::vector<Sequence>&
getSequences
();
56
57
[[nodiscard]]
const
Sequence
*
getSequenceFromID
(uint32_t
id
)
const
;
58
59
[[nodiscard]]
Sequence
*
getSequenceFromID
(uint32_t
id
);
60
61
[[nodiscard]] uint8_t
getFrameBoundsCount
()
const
;
62
63
[[nodiscard]] std::vector<std::byte>
bake
()
const
;
64
65
bool
bake
(
const
std::filesystem::path& shtPath)
const
;
// NOLINT(*-use-nodiscard)
66
67
protected
:
68
bool
opened
;
69
70
uint32_t
version
= 0;
71
std::vector<Sequence>
sequences
;
72
};
73
74
}
// namespace vtfpp
Math.h
vtfpp::SHT::getSequenceFromID
const Sequence * getSequenceFromID(uint32_t id) const
Definition
SHT.cpp:62
vtfpp::SHT::version
uint32_t version
Definition
SHT.h:70
vtfpp::SHT::opened
bool opened
Definition
SHT.h:68
vtfpp::SHT::sequences
std::vector< Sequence > sequences
Definition
SHT.h:71
vtfpp::SHT::setVersion
void setVersion(uint32_t v)
Definition
SHT.cpp:47
vtfpp::SHT::getVersion
uint32_t getVersion() const
Definition
SHT.cpp:43
vtfpp::SHT::getFrameBoundsCount
uint8_t getFrameBoundsCount() const
Definition
SHT.cpp:80
vtfpp::SHT::bake
std::vector< std::byte > bake() const
Definition
SHT.cpp:84
vtfpp::SHT::getSequences
const std::vector< Sequence > & getSequences() const
Definition
SHT.cpp:54
vtfpp::SHT::SHT
SHT()
Definition
SHT.cpp:10
vtfpp
Definition
DistanceMapping.h:8
vtfpp::SHT::Sequence::Frame::Bounds
Definition
SHT.h:16
vtfpp::SHT::Sequence::Frame::Bounds::y2
float y2
Definition
SHT.h:20
vtfpp::SHT::Sequence::Frame::Bounds::x1
float x1
Definition
SHT.h:17
vtfpp::SHT::Sequence::Frame::Bounds::y1
float y1
Definition
SHT.h:18
vtfpp::SHT::Sequence::Frame::Bounds::x2
float x2
Definition
SHT.h:19
vtfpp::SHT::Sequence::Frame
Definition
SHT.h:15
vtfpp::SHT::Sequence::Frame::duration
float duration
Definition
SHT.h:23
vtfpp::SHT::Sequence::Frame::setAllBounds
void setAllBounds(Bounds newBounds)
Definition
SHT.h:27
vtfpp::SHT::Sequence::Frame::bounds
std::array< Bounds, 4 > bounds
Definition
SHT.h:25
vtfpp::SHT::Sequence
Definition
SHT.h:14
vtfpp::SHT::Sequence::id
uint32_t id
Definition
SHT.h:35
vtfpp::SHT::Sequence::loop
bool loop
Definition
SHT.h:36
vtfpp::SHT::Sequence::durationTotal
float durationTotal
Definition
SHT.h:38
vtfpp::SHT::Sequence::frames
std::vector< Frame > frames
Definition
SHT.h:37
include
vtfpp
SHT.h
Generated on
for SourcePP by
1.17.0