Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
OptionsHelpRuntime.hpp
Go to the documentation of this file.
1#pragma once
2#include "OptionsUI.hpp"
3#include "ResourceRuntime.hpp"
4#include <expected>
5#include <cstdint>
6#include <filesystem>
7#include <functional>
8#include <optional>
9#include <string>
10#include <string_view>
11namespace monopoly::optionsui
12{
13 [[nodiscard]] std::string helpFileName(data::LanguageId language, bool fullHelp);
14 // Only the known self-contained UTF-8 exporter structure is styled. An absent
15 // result leaves unknown, malformed, already themed or oversized HTML untouched.
16 [[nodiscard]] std::optional<std::string> styleFullHelpHtml(
17 std::string_view html, std::uintmax_t maximumBytes);
18 // The supplied western qhelp01..10 files use single-byte text. CP1252 is
19 // a portable choice compatible with every byte present in that corpus;
20 // those files alone do not distinguish CP1252 from ISO-8859-1.
21 [[nodiscard]] std::expected<std::string, std::string> decodeQuickHelpText(
22 std::string_view bytes);
23 [[nodiscard]] std::expected<void, std::string> openQuickHelp(
24 State& state, const data::ResourceSnapshot& resources);
26 {
27 // An executable path, never a shell command. Empty uses MONOPOLY_WINHLP
28 // when defined, otherwise the winhlp executable available on PATH.
29 std::string exporterExecutable;
30 std::uint32_t timeoutMilliseconds{30000};
31 std::uintmax_t maximumHtmlBytes{32 * 1024 * 1024};
32 // Optional embedding/test seam. On Windows this runs on an owned worker;
33 // it must not call SDL or capture game state. Empty uses the native shell.
34 std::function<std::expected<void, std::string>(const std::filesystem::path&)> openDocument;
35 };
36
37 // Starts a nonblocking HLP -> self-contained HTML export in the user's
38 // preference directory. Original resources are opened read-only.
39 [[nodiscard]] std::expected<void, std::string> openFullHelp(
40 const data::ResourceSnapshot& resources, const FullHelpOptions& options = {});
41 // Called on the application thread: false = idle/pending, true = a completed
42 // document was handed to the default browser. Errors are consumed once.
43 // Windows shell dispatch never blocks this thread. A timed-out/cancelled OS
44 // request may still finish; no second worker starts until the first returns.
45 [[nodiscard]] std::expected<bool, std::string> pollFullHelp();
48}
std::vector< std::byte > bytes
unsigned state
unsigned index
void cancelFullHelp() noexcept
bool fullHelpPending() noexcept
std::expected< void, std::string > openQuickHelp(State &state, const data::ResourceSnapshot &resources)
std::expected< std::string, std::string > decodeQuickHelpText(std::string_view bytes)
std::optional< std::string > styleFullHelpHtml(std::string_view html, std::uintmax_t maximumBytes)
std::expected< bool, std::string > pollFullHelp()
std::expected< void, std::string > openFullHelp(const data::ResourceSnapshot &resources, const FullHelpOptions &options)
std::string helpFileName(data::LanguageId language, bool fullHelp)
std::function< std::expected< void, std::string >(const std::filesystem::path &)> openDocument