Porytiles
Loading...
Searching...
No Matches
prefilled_palette.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <compare>
4#include <cstddef>
5
8
9namespace porytiles {
10
24 public:
36 [[nodiscard]] static PrefilledPalette
37 fully_locked(std::size_t hardware_index, ColorSet color_set, std::size_t occupied_slots);
38
52 [[nodiscard]] static PrefilledPalette partially_locked(
53 std::size_t hardware_index,
55 std::size_t occupied_slots,
56 std::size_t total_capacity = palette::max_size - 1);
57
58 [[nodiscard]] bool operator==(const PrefilledPalette &other) const
59 {
60 return hardware_index_ == other.hardware_index_;
61 }
62
63 [[nodiscard]] std::strong_ordering operator<=>(const PrefilledPalette &other) const
64 {
65 return hardware_index_ <=> other.hardware_index_;
66 }
67
68 [[nodiscard]] std::size_t hardware_index() const
69 {
70 return hardware_index_;
71 }
72
73 [[nodiscard]] const ColorSet &fixed_colors() const
74 {
75 return fixed_colors_;
76 }
77
78 [[nodiscard]] std::size_t fixed_color_count() const;
79
80 [[nodiscard]] std::size_t occupied_slots() const
81 {
82 return occupied_slots_;
83 }
84
85 [[nodiscard]] std::size_t available_capacity() const
86 {
87 return available_capacity_;
88 }
89
90 [[nodiscard]] bool is_fully_locked() const
91 {
92 return available_capacity_ == 0;
93 }
94
104 [[nodiscard]] bool can_accommodate(const ColorSet &tile_colors) const;
105
106 private:
108 std::size_t hardware_index, ColorSet fixed_colors, std::size_t available_capacity, std::size_t occupied_slots);
109
110 std::size_t hardware_index_;
111 ColorSet fixed_colors_;
112 std::size_t available_capacity_;
113 std::size_t occupied_slots_;
114};
115
116} // namespace porytiles
A set of colors represented as a bitset.
Definition color_set.hpp:22
Pre-assigned palette with wildcard support for palette packing.
std::size_t fixed_color_count() const
static PrefilledPalette fully_locked(std::size_t hardware_index, ColorSet color_set, std::size_t occupied_slots)
Creates a fully locked PrefilledPalette.
std::strong_ordering operator<=>(const PrefilledPalette &other) const
static PrefilledPalette partially_locked(std::size_t hardware_index, ColorSet fixed_colors, std::size_t occupied_slots, std::size_t total_capacity=palette::max_size - 1)
Creates a partially locked palette with available capacity.
std::size_t hardware_index() const
std::size_t available_capacity() const
bool can_accommodate(const ColorSet &tile_colors) const
Checks if a tile's colors can be accommodated by this palette.
std::size_t occupied_slots() const
bool operator==(const PrefilledPalette &other) const
const ColorSet & fixed_colors() const
constexpr std::size_t max_size
Definition palette.hpp:19