Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
IBarLayout.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <optional>
5
7{
8 inline constexpr int VirtualWidth = 800;
9 inline constexpr int VirtualHeight = 600;
10
11 inline constexpr int ScoreY = 560;
12
13 inline constexpr int ScoreBorder = 2;
14
15 inline constexpr int BankWidth = 45;
16
17 inline constexpr int ScoreBoxSmallWidth = 127;
18
19 inline constexpr int ScoreBoxLargeWidth = 184;
20
21
22 enum class ActionButtonSlot : int
23 {
24 Options = 0,
25 Trade,
30 Main,
31 Camera,
32 Status,
33
34 Count
35 };
36
37
38 enum class ActionButtonLayout : int
39 {
40 General = 0,
44 };
45
46
47 struct Rect
48 {
49 int left = 0;
50 int top = 0;
51 int right = 0;
52 int bottom = 0;
53
54
55 [[nodiscard]]
57 int x,
58 int y
59 ) const noexcept
60 {
61 // Win32 PtInRect :
62 // right / bottom exclus.
63 return
64 x >= left &&
65 x < right &&
66 y >= top &&
67 y < bottom;
68 }
69 };
70
71
72 [[nodiscard]]
73 int scoreBoxWidth(
74 int numberOfPlayers
75 ) noexcept;
76
77
78 [[nodiscard]]
79 int scoreX(
80 int playerIndex,
81 int numberOfPlayers,
82 int playerWidth
83 ) noexcept;
84
85
86 [[nodiscard]]
88 int playerIndex,
89 int numberOfPlayers
90 ) noexcept;
91
93 {
95 }
96
97
98 [[nodiscard]]
102 ) noexcept;
103
104
105 using PropertyMask = std::uint32_t;
106
107 [[nodiscard]] int propertyIndex(int square) noexcept;
108 [[nodiscard]] PropertyMask propertyBit(int square) noexcept;
109 [[nodiscard]] int propertyBarOrder(int square) noexcept;
110 [[nodiscard]] Rect propertyRect(int square) noexcept;
111 [[nodiscard]] std::optional<int> propertyHit(
112 int x, int y, PropertyMask visibleProperties) noexcept;
113
114
115 using ActionButtonMask = unsigned int;
116
117 [[nodiscard]]
119 {
120 return 1u << static_cast<unsigned int>(slot);
121 }
122
124 (1u << static_cast<unsigned int>(ActionButtonSlot::Count)) - 1u;
125
126
127 [[nodiscard]]
128 std::optional<ActionButtonSlot> actionButtonHit(
129 int x,
130 int y,
133 ) noexcept;
134}
PlayerNumber slot
unsigned index
int propertyIndex(int square) noexcept
constexpr ActionButtonMask AllActionButtonSlots
std::uint32_t PropertyMask
Rect propertyRect(int square) noexcept
int scoreX(int playerIndex, int numberOfPlayers, int playerWidth) noexcept
PropertyMask propertyBit(int square) noexcept
std::optional< int > propertyHit(int x, int y, PropertyMask visibleProperties) noexcept
std::optional< ActionButtonSlot > actionButtonHit(int x, int y, ActionButtonLayout layout, ActionButtonMask activeSlots) noexcept
Rect actionButtonRect(ActionButtonSlot slot, ActionButtonLayout layout) noexcept
constexpr int VirtualHeight
Definition IBarLayout.hpp:9
constexpr int ScoreBorder
unsigned int ActionButtonMask
constexpr int VirtualWidth
Definition IBarLayout.hpp:8
constexpr Rect bankHitRect() noexcept
constexpr int ScoreBoxSmallWidth
int scoreBoxWidth(int numberOfPlayers) noexcept
Rect playerSetupHitRect(int playerIndex, int numberOfPlayers) noexcept
int propertyBarOrder(int square) noexcept
constexpr int BankWidth
constexpr int ScoreBoxLargeWidth
constexpr ActionButtonMask actionButtonBit(ActionButtonSlot slot) noexcept
bool contains(int x, int y) const noexcept