Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
SequenceWorld2DSlot.hpp
Go to the documentation of this file.
1#pragma once
2#include "BitmapRuntime.hpp"
3#include "RenderSlots.hpp"
5#include <map>
6
7namespace monopoly::ibar { class ModernIBarSkin; }
8namespace monopoly::menu { class ModernMenuSkin; }
9
10namespace monopoly::engine
11{
13 {
16 std::uint16_t priority{};
17 std::int32_t clock{};
19 std::shared_ptr<const data::BitmapRuntimeAsset> asset;
20 };
22 {
23 std::size_t started{}, moved{}, stopped{}, unchanged{};
24 };
26 {
27 public:
28 [[nodiscard]] static constexpr RenderSlot slot() noexcept
29 { return RenderSlot::Overlay2D; }
30 [[nodiscard]] std::expected<SequenceWorld2DSyncStats, std::string> sync(
31 const std::vector<sequence::SequenceBitmapRenderItem>& items,
33 // nullptr preserves the complete legacy bitmap path. The skin changes pixels only.
34 void configureModernIBarSkin(std::shared_ptr<ibar::ModernIBarSkin> skin) noexcept
35 { modernSkin_ = std::move(skin); }
36 void configureModernMenuSkin(std::shared_ptr<menu::ModernMenuSkin> skin) noexcept
37 { modernMenuSkin_ = std::move(skin); }
38 // Removing sequence objects does not uninstall the legacy render slot:
39 // its last camera remains until another label owner supplies a view.
40 void clear() noexcept { objects_.clear(); order_.clear(); }
41 void updateCamera(const std::optional<sequence::SequenceCamera2DView>& camera) noexcept;
43 { return worldToScreen_; }
45 { return screenToWorld_; }
46 [[nodiscard]] static constexpr std::uint8_t cameraLabel() noexcept { return 1; }
47 [[nodiscard]] static std::array<std::int32_t, 2> transformPoint(
48 const sequence::Matrix2D& matrix, std::int32_t x, std::int32_t y) noexcept;
49 [[nodiscard]] static std::array<std::int32_t, 2> boundsCenter(
51 const data::Sequence2DBoundingBoxAttribute& bounds) noexcept;
52 [[nodiscard]] std::size_t size() const noexcept { return objects_.size(); }
54 { const auto it = objects_.find(id); return it == objects_.end() ? nullptr : &it->second; }
55 [[nodiscard]] const std::vector<sequence::SequenceNodeId>& order() const noexcept
56 { return order_; }
57 private:
58 std::array<std::int32_t, 2> cameraCenter_{400, 300};
59 float cameraRotation_{};
60 float cameraScale_{1.0F};
61 sequence::Matrix2D worldToScreen_{sequence::identity2D()};
62 sequence::Matrix2D screenToWorld_{sequence::identity2D()};
63 std::shared_ptr<ibar::ModernIBarSkin> modernSkin_;
64 std::shared_ptr<menu::ModernMenuSkin> modernMenuSkin_;
65 std::map<sequence::SequenceNodeId, SequenceWorld2DObject> objects_;
66 std::vector<sequence::SequenceNodeId> order_;
67 };
68}
unsigned index
static std::array< std::int32_t, 2 > boundsCenter(const sequence::Matrix2D &matrix, const data::Sequence2DBoundingBoxAttribute &bounds) noexcept
void updateCamera(const std::optional< sequence::SequenceCamera2DView > &camera) noexcept
static constexpr RenderSlot slot() noexcept
void configureModernMenuSkin(std::shared_ptr< menu::ModernMenuSkin > skin) noexcept
static constexpr std::uint8_t cameraLabel() noexcept
const sequence::Matrix2D & screenToWorld() const noexcept
const sequence::Matrix2D & worldToScreen() const noexcept
const SequenceWorld2DObject * find(sequence::SequenceNodeId id) const noexcept
static std::array< std::int32_t, 2 > transformPoint(const sequence::Matrix2D &matrix, std::int32_t x, std::int32_t y) noexcept
std::expected< SequenceWorld2DSyncStats, std::string > sync(const std::vector< sequence::SequenceBitmapRenderItem > &items, data::BitmapRuntimeCache &cache)
const std::vector< sequence::SequenceNodeId > & order() const noexcept
void configureModernIBarSkin(std::shared_ptr< ibar::ModernIBarSkin > skin) noexcept
std::uint32_t DataId
Definition DataBanks.hpp:10
Matrix2D identity2D() noexcept
std::uint64_t SequenceNodeId
std::shared_ptr< const data::BitmapRuntimeAsset > asset