Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
StatsCalculatorUI.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Display.hpp"
4#include "IBarLayout.hpp"
6#include "StatsUI.hpp"
7#include "UIMessages.hpp"
8
9#include <cstdint>
10#include <optional>
11#include <string>
12
13namespace monopoly::statsui
14{
15 enum class CalculatorStep : std::uint8_t
16 {
17 RollOver = 0,
18 First,
19 Second,
20 Third,
21 Fourth
22 };
23
24 enum class CalculatorPicker : std::uint8_t
25 {
26 None = 0,
27 Deed,
28 Player
29 };
31 {
34 std::optional<std::uint8_t> hoveredFunction;
35 std::optional<int> hoveredDeed;
36 std::optional<CalculatorFunction> activeFunction;
38 std::optional<CalculatorResult> result;
39 std::optional<std::string> error;
40 std::optional<std::uint8_t> pressedNumber;
41 bool visible{};
42 };
43
45 std::uint8_t index) noexcept
46 {
47 const int left = 410 + 49 * static_cast<int>(index % 2);
48 const int top = 47 + 34 * static_cast<int>(index / 2);
49 return {left, top, left + 47, top + 29};
50 }
51
53 std::uint8_t index) noexcept
54 {
55 if (index == 10) return {540, 169, 590, 194};
56 const int left = 514 + 26 * static_cast<int>(index % 3);
57 const int top = 79 + 30 * static_cast<int>(index / 3);
58 return {left, top, left + 24, top + 25};
59 }
61 rules::PlayerNumber player) noexcept
62 {
63 const int column = static_cast<int>(player % 2);
64 const int row = static_cast<int>(player / 2);
65 const int left = 514 + (column == 0 ? 0 : 46);
66 const int top = 79 + 30 * row;
67 return {left, top, left + 42, top + 20};
68 }
69
70 [[nodiscard]] std::optional<Rect> calculatorDeedRect(
71 int square) noexcept;
72 [[nodiscard]] std::optional<std::uint8_t> calculatorFunctionHit(
73 int x, int y) noexcept;
74 [[nodiscard]] std::optional<rules::PlayerNumber> calculatorTokenHit(
75 const rules::GameState& state, int x, int y) noexcept;
76 [[nodiscard]] std::optional<int> calculatorDeedHit(
77 int x, int y) noexcept;
78
79 void resetCalculatorUI(CalculatorUIState& state) noexcept;
81 CalculatorUIState& state, display::Screen2D view) noexcept;
83 CalculatorUIState& state, const rules::GameState& gameState,
84 display::Screen2D view, const uimsg::Message& message) noexcept;
85}
std::atomic< float > left
int top
unsigned state
unsigned index
std::uint8_t PlayerNumber
Definition RuleTypes.hpp:12
bool processCalculatorInput(CalculatorUIState &state, const rules::GameState &gameState, display::Screen2D view, const uimsg::Message &message) noexcept
std::optional< Rect > calculatorDeedRect(int square) noexcept
constexpr Rect calculatorTokenRect(rules::PlayerNumber player) noexcept
std::optional< std::uint8_t > calculatorFunctionHit(int x, int y) noexcept
void resetCalculatorUI(CalculatorUIState &state) noexcept
constexpr Rect calculatorFunctionRect(std::uint8_t index) noexcept
void syncCalculatorView(CalculatorUIState &state, display::Screen2D view) noexcept
constexpr Rect calculatorNumberRect(std::uint8_t index) noexcept
std::optional< rules::PlayerNumber > calculatorTokenHit(const rules::GameState &state, int x, int y) noexcept
std::optional< int > calculatorDeedHit(int x, int y) noexcept
std::optional< std::uint8_t > pressedNumber
std::optional< std::string > error
std::optional< std::uint8_t > hoveredFunction
std::optional< CalculatorResult > result
std::optional< CalculatorFunction > activeFunction