Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
OptionsCustomBoardRuntime.hpp
Go to the documentation of this file.
1#pragma once
2#include "OptionsUI.hpp"
3#include "ResourceRuntime.hpp"
4#include <array>
5#include <expected>
6#include <filesystem>
7#include <optional>
8#include <string>
9#include <string_view>
10#include <vector>
11namespace monopoly::optionsui
12{
13 inline constexpr std::size_t CustomBoardLimit = 100;
14 inline constexpr std::size_t CustomBoardPageSize = 5;
16 {
17 std::filesystem::path fileName;
18 std::string displayName; // UTF-8, including the .brd extension.
19 };
21 {
22 bool active{};
24 std::filesystem::path directory;
25 std::vector<CustomBoardEntry> entries;
26 std::size_t pageOffset{};
28 std::array<Rect, 4> buttonRects{}; // Okay, Cancel, Back, Next.
29 std::uint64_t revision{};
30 };
32 {
33 std::filesystem::path boardFile;
34 std::filesystem::path assetRoot;
35 };
37 {
38 bool consumed{};
39 bool playClick{};
42 };
43 [[nodiscard]] Rect customBoardSlotRect(std::size_t slot) noexcept;
44 [[nodiscard]] bool customBoardHasPrevious(const CustomBoardState& state) noexcept;
45 [[nodiscard]] bool customBoardHasNext(const CustomBoardState& state) noexcept;
46 [[nodiscard]] std::expected<void, std::string> openCustomBoardDialog(
47 CustomBoardState& state, const std::filesystem::path& moduleDirectory,
48 display::Screen2D previousView);
49 void closeCustomBoardDialog(CustomBoardState& state) noexcept;
50 [[nodiscard]] CustomBoardInput processCustomBoardInput(
51 CustomBoardState& state, const uimsg::Message& message) noexcept;
52 // Original 32-bit game's HKLM REG_BINARY Version, never a generated value.
53 [[nodiscard]] std::expected<std::uint32_t, std::string> readCustomBoardSecurityVersion();
54 // Explicit verifier also permits fixture tests without modifying the registry.
55 [[nodiscard]] std::expected<CustomBoardSelection, std::string> validateCustomBoardFile(
56 const std::filesystem::path& directory, const std::filesystem::path& fileName,
57 std::uint32_t installedSecurityVersion);
58 [[nodiscard]] std::expected<CustomBoardSelection, std::string> validateSelectedCustomBoard(
59 const CustomBoardState& state);
60 // SetUpLoadedGame restores the saved asset directory, without requiring
61 // the original .brd ownership file or editor registry. A missing first
62 // camera means the board was removed and requests the retail stock fallback.
63 // Other errors fail before the caller publishes any loaded-game state.
64 [[nodiscard]] std::expected<std::optional<std::filesystem::path>, std::string>
66 const data::ResourceSnapshot& resources, int monetarySystem);
67}
PlayerNumber slot
unsigned state
unsigned index
std::filesystem::path directory
Rect customBoardSlotRect(std::size_t slot) noexcept
CustomBoardInput processCustomBoardInput(CustomBoardState &state, const uimsg::Message &message) noexcept
void closeCustomBoardDialog(CustomBoardState &state) noexcept
constexpr std::size_t CustomBoardLimit
std::expected< std::optional< std::filesystem::path >, std::string > restoreSavedCustomBoard(std::string_view savedAssetRoot, const data::ResourceSnapshot &resources, int monetarySystem)
constexpr std::size_t CustomBoardPageSize
std::expected< void, std::string > openCustomBoardDialog(CustomBoardState &state, const std::filesystem::path &moduleDirectory, display::Screen2D previousView)
bool customBoardHasNext(const CustomBoardState &state) noexcept
bool customBoardHasPrevious(const CustomBoardState &state) noexcept
std::expected< CustomBoardSelection, std::string > validateCustomBoardFile(const std::filesystem::path &directory, const std::filesystem::path &fileName, std::uint32_t installedSecurityVersion)
std::expected< CustomBoardSelection, std::string > validateSelectedCustomBoard(const CustomBoardState &state)
std::expected< std::uint32_t, std::string > readCustomBoardSecurityVersion()