coastline 0.0.4
Loading...
Searching...
No Matches
config.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstddef>
5#include <filesystem>
6#include <map>
7#include <optional>
8#include <string>
9#include <string_view>
10
11namespace coastline {
12
19public:
28
36
44 bool Save(const std::filesystem::path &path) const;
45
52
59 long GetInteger(std::string_view section, std::string_view key, long fallback) const;
60
68 int
69 GetIndex(std::string_view section, std::string_view key, std::size_t count, int fallback) const;
70
77 float GetFloat(std::string_view section, std::string_view key, float fallback) const;
78
85 bool GetBoolean(std::string_view section, std::string_view key, bool fallback) const;
86
95
96private:
97 void ResetInvalidSettings();
99 struct CaseInsensitiveLess {
101 using is_transparent = void;
103 bool operator()(std::string_view left, std::string_view right) const;
104 };
107};
108
116
126std::array<int, 2> ExpandInternalResolution(int width, int height, float aspect);
127
136std::array<int, 2> ScaleFrameResolution(int width, int height, float scale, float aspect);
137
138} // namespace coastline
The settings of BossRally.ini.
Definition config.h:18
long GetInteger(std::string_view section, std::string_view key, long fallback) const
bool Save(const std::filesystem::path &path) const
Atomically replace path under a process lock.
void Set(std::string_view section, std::string_view key, std::string value)
Store a value, replacing any value of the same key.
static GameConfig Load(const std::filesystem::path &path)
Read path.
int GetIndex(std::string_view section, std::string_view key, std::size_t count, int fallback) const
float GetFloat(std::string_view section, std::string_view key, float fallback) const
std::optional< std::string > Get(std::string_view section, std::string_view key) const
static GameConfig Parse(std::string_view text)
Parse INI section headers, Key=Value lines, and comments that start with ; or #.
bool GetBoolean(std::string_view section, std::string_view key, bool fallback) const
Definition assetimport.h:11
std::optional< float > ParseAspectRatio(std::string_view text)
Read a finite, positive aspect ratio or an automatic-sizing setting.
std::array< int, 2 > ScaleFrameResolution(int width, int height, float scale, float aspect)
Scale window dimensions and fit an aspect ratio before bounded integer conversion.
std::array< int, 2 > ExpandInternalResolution(int width, int height, float aspect)
Expand a resolution to an aspect ratio, with minimum dimensions of 320x240.