PCG-FPS  v2 m0.22.4
Simple First Person Shooter with Procedurally Generated Level
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
skr::fps2::Settings Class Reference

managing and handling of settings for program More...

#include <Settings.h>

Public Types

enum  SettingUInt32t { SettingUInt32t::SCR_WIDTH, SettingUInt32t::SCR_HEIGHT, SettingUInt32t::RNG_MODE, SettingUInt32t::RNG_SEED }
 identifiers for settings of type unsigned integer More...
 
enum  SettingFloat { SettingFloat::RND_NEAR, SettingFloat::RND_FAR }
 identifies for settings of type float More...
 
enum  SettingBool { SettingBool::RND_VSYNC, SettingBool::RNG_PRINTSEED, SettingBool::RND_GAMMACORRECTION, SettingBool::RND_COLORCODEDROOMS }
 identifiers for settings of type boolean More...
 
enum  RuntimeBoolSetting {
  RuntimeBoolSetting::GhostMode, RuntimeBoolSetting::DrawDebugLight, RuntimeBoolSetting::MoveLights, RuntimeBoolSetting::DrawBoundingBox,
  RuntimeBoolSetting::UseNormalMapping
}
 identifiers for settings of type bool only relevant during runtime, they are not written to the settings file More...
 
enum  ShadowType { ShadowType::Off, ShadowType::ShadowMapping, ShadowType::ShadowMappingPCF, ShadowType::ShadowMappingPCFDisk }
 type identifies for shadow mapping types More...
 

Public Member Functions

bool WriteSettingsToFile ()
 write settings to path in _settingsFilePath More...
 
bool WriteSettingsToFile (const std::string path)
 write settings to given path More...
 
bool ReadSettingsFromFile ()
 read settings from path set in _settingsFilePath More...
 
bool ReadSettingsFromFile (const std::string path)
 read settings from given path More...
 
std::string PrintSettingsToString ()
 write all settings into a single string used to write everything in one big chunk More...
 

Static Public Member Functions

static SettingsGetInstance ()
 Get only instance of this class Implements Scott Meyers' singleton pattern. More...
 

Public Attributes

std::unordered_map< SettingUInt32t, uint32_t > _settings_uint32t
 map keeping settings of type unsigned integer and their values More...
 
std::unordered_map< SettingFloat, float > _settings_float
 map keeping settings of type float and their values More...
 
std::unordered_map< SettingBool, bool > _settings_bool
 map keeping settings of type boolean and their values More...
 
std::unordered_map< RuntimeBoolSetting, bool > _runtime_bool
 map keeping settings of type bool only relevant during runtime More...
 
ShadowType _shadowRenderingMode = ShadowType::ShadowMappingPCF
 type of shadow mapping currently used More...
 

Private Types

typedef std::unordered_map< std::string, SettingUInt32tStringToSettingIntMap
 typedef to map a string to a setting of type unsigned integer More...
 
typedef std::unordered_map< SettingUInt32t, std::string > SettingIntToStringMap
 typedef to map settings of type unsigned integer to a string More...
 
typedef std::unordered_map< SettingFloat, std::string > SettingFloatToStringMap
 typedef to map a setting of type flaot to a string More...
 
typedef std::unordered_map< std::string, SettingFloatStringToSettingFloatMap
 typedef to map a string to a setting of type float More...
 
typedef std::unordered_map< SettingBool, std::string > SettingBoolToStringMap
 typedef mapping a setting of type boolean to a string More...
 
typedef std::unordered_map< std::string, SettingBoolStringToSettinBoolMap
 typedef mapping a string to a setting of type boolean More...
 

Private Member Functions

 Settings ()
 default constructor empty as OpenGL-Renderer object is a global object an requiers one at launch, even though it does nothing More...
 
 Settings (const Settings &)=delete
 copy constructor is deleted More...
 
Settings operator= (const Settings &)=delete
 copy assignment constructor is deleted More...
 
bool GetSettingsFromFile (const std::string path, std::vector< std::string > &settings)
 read settings from a file into a list of strings More...
 
bool SetSettingsFromString (std::vector< std::string > settings)
 set settings from a list of strings goes through a list of settings, one per element, and sets values in maps accordingly More...
 
std::string GetHumanReadableBool (bool v)
 Get boolean value in human readable form: true/false instead of 1/0. More...
 

Private Attributes

std::string _settingsFilePath = "settings.cfg"
 

Static Private Attributes

static const std::unordered_map< std::string, SettingUInt32tMapStringToSettingInt
 mapping table for string to setting of type unsinged integer More...
 
static const std::unordered_map< SettingUInt32t, std::string > MapSettingIntToString
 mapping table for settings of type unsigned integer to a string More...
 
static const std::unordered_map< SettingFloat, std::string > MapSettingFloatToString
 mapping table from a setting of type float to a string More...
 
static const std::unordered_map< std::string, SettingFloatMapStringToSettingFloat
 mapping table from a string to setting of type float More...
 
static const std::unordered_map< SettingBool, std::string > MapSettingBoolToString
 mapping table to map a setting of type boolean to a string More...
 
static const std::unordered_map< std::string, SettingBoolMapStringToSettingBool
 mapping table from a string to a setting of type boolean More...
 

Detailed Description

managing and handling of settings for program

Implements Scott Meyers' singleton pattern

Member Typedef Documentation

◆ SettingBoolToStringMap

typedef std::unordered_map<SettingBool, std::string> skr::fps2::Settings::SettingBoolToStringMap
private

typedef mapping a setting of type boolean to a string

◆ SettingFloatToStringMap

typedef std::unordered_map<SettingFloat, std::string> skr::fps2::Settings::SettingFloatToStringMap
private

typedef to map a setting of type flaot to a string

◆ SettingIntToStringMap

typedef std::unordered_map<SettingUInt32t, std::string> skr::fps2::Settings::SettingIntToStringMap
private

typedef to map settings of type unsigned integer to a string

◆ StringToSettinBoolMap

typedef std::unordered_map<std::string, SettingBool> skr::fps2::Settings::StringToSettinBoolMap
private

typedef mapping a string to a setting of type boolean

◆ StringToSettingFloatMap

typedef std::unordered_map<std::string, SettingFloat> skr::fps2::Settings::StringToSettingFloatMap
private

typedef to map a string to a setting of type float

◆ StringToSettingIntMap

typedef std::unordered_map<std::string, SettingUInt32t> skr::fps2::Settings::StringToSettingIntMap
private

typedef to map a string to a setting of type unsigned integer

Member Enumeration Documentation

◆ RuntimeBoolSetting

identifiers for settings of type bool only relevant during runtime, they are not written to the settings file

Enumerator
GhostMode 

flag indicating if ghost mode is active (no collision + fly)

DrawDebugLight 

flag indicating to draw a cube at position of every light

MoveLights 

flag indicating if lights are moving or static

DrawBoundingBox 

flag indicating if bounding boxes of geometry are draw

UseNormalMapping 

flag indicating if normal mapping is active

◆ SettingBool

identifiers for settings of type boolean

Enumerator
RND_VSYNC 

vertical synchronization on/off

RNG_PRINTSEED 

print seed to cmd and log on/off

RND_GAMMACORRECTION 

use gamma correction of/off

RND_COLORCODEDROOMS 

color code rooms on/off

◆ SettingFloat

identifies for settings of type float

Enumerator
RND_NEAR 

distance of near plane

RND_FAR 

distance of far plane

◆ SettingUInt32t

identifiers for settings of type unsigned integer

Enumerator
SCR_WIDTH 

viewport width

SCR_HEIGHT 

viewport height

RNG_MODE 

mode of procedural generation

RNG_SEED 

seed for random number generator used in procedural generation

◆ ShadowType

type identifies for shadow mapping types

Enumerator
Off 

shadow mapping off

ShadowMapping 

simple shadow mapping

ShadowMappingPCF 

shadow mapping with Percentage-closer filtering

ShadowMappingPCFDisk 

shadow mapping with Percentage-closer filtering with fixed samples

Constructor & Destructor Documentation

◆ Settings() [1/2]

skr::fps2::Settings::Settings ( )
inlineprivate

default constructor empty as OpenGL-Renderer object is a global object an requiers one at launch, even though it does nothing

◆ Settings() [2/2]

skr::fps2::Settings::Settings ( const Settings )
privatedelete

copy constructor is deleted

Member Function Documentation

◆ GetHumanReadableBool()

std::string skr::fps2::Settings::GetHumanReadableBool ( bool  v)
private

Get boolean value in human readable form: true/false instead of 1/0.

Parameters
vboolean value return human readable string of boolean value

◆ GetInstance()

Settings & skr::fps2::Settings::GetInstance ( )
static

Get only instance of this class Implements Scott Meyers' singleton pattern.

◆ GetSettingsFromFile()

bool skr::fps2::Settings::GetSettingsFromFile ( const std::string  path,
std::vector< std::string > &  settings 
)
private

read settings from a file into a list of strings

Parameters
pathPath settings are read from
[out]settingsreference to list of strings settings will be read to
Returns
true if read operation was successful, otherwise false.

◆ operator=()

Settings skr::fps2::Settings::operator= ( const Settings )
privatedelete

copy assignment constructor is deleted

◆ PrintSettingsToString()

std::string skr::fps2::Settings::PrintSettingsToString ( )

write all settings into a single string used to write everything in one big chunk

Returns
string containing all settings

◆ ReadSettingsFromFile() [1/2]

bool skr::fps2::Settings::ReadSettingsFromFile ( )

read settings from path set in _settingsFilePath

Returns
true if read was successful, otherwise false

◆ ReadSettingsFromFile() [2/2]

bool skr::fps2::Settings::ReadSettingsFromFile ( const std::string  path)

read settings from given path

Parameters
pathpath to file settings are read from
Returns
truen if read was successful, otherwise false

◆ SetSettingsFromString()

bool skr::fps2::Settings::SetSettingsFromString ( std::vector< std::string >  settings)
private

set settings from a list of strings goes through a list of settings, one per element, and sets values in maps accordingly

Parameters
settingslist of settings
Returns
bool if operation was successful, otherwise false

◆ WriteSettingsToFile() [1/2]

bool skr::fps2::Settings::WriteSettingsToFile ( )

write settings to path in _settingsFilePath

Returns
true if write operation was successfull, otherwise false

◆ WriteSettingsToFile() [2/2]

bool skr::fps2::Settings::WriteSettingsToFile ( const std::string  path)

write settings to given path

Parameters
pathpath settings will be written to
Returns
true if write operation was successful, otherwise false

Member Data Documentation

◆ _runtime_bool

std::unordered_map<RuntimeBoolSetting, bool> skr::fps2::Settings::_runtime_bool
Initial value:

map keeping settings of type bool only relevant during runtime

◆ _settings_bool

std::unordered_map<SettingBool, bool> skr::fps2::Settings::_settings_bool
Initial value:

map keeping settings of type boolean and their values

◆ _settings_float

std::unordered_map<SettingFloat, float> skr::fps2::Settings::_settings_float
Initial value:

map keeping settings of type float and their values

◆ _settings_uint32t

std::unordered_map<SettingUInt32t, uint32_t> skr::fps2::Settings::_settings_uint32t
Initial value:

map keeping settings of type unsigned integer and their values

◆ _settingsFilePath

std::string skr::fps2::Settings::_settingsFilePath = "settings.cfg"
private

path to settings file default: settings.cfg in local folder

◆ _shadowRenderingMode

ShadowType skr::fps2::Settings::_shadowRenderingMode = ShadowType::ShadowMappingPCF

type of shadow mapping currently used

◆ MapSettingBoolToString

const Settings::SettingBoolToStringMap skr::fps2::Settings::MapSettingBoolToString
staticprivate
Initial value:
=
{
{SettingBool::RND_VSYNC, "rnd_vsync"},
{SettingBool::RNG_PRINTSEED, "rng_printseed"},
{SettingBool::RND_GAMMACORRECTION, "rnd_gammacorrection"},
{SettingBool::RND_COLORCODEDROOMS, "rnd_colorcoderooms"},
}

mapping table to map a setting of type boolean to a string

◆ MapSettingFloatToString

const Settings::SettingFloatToStringMap skr::fps2::Settings::MapSettingFloatToString
staticprivate
Initial value:
=
{
{SettingFloat::RND_NEAR, "rnd_near"},
{SettingFloat::RND_FAR, "rnd_far"},
}

mapping table from a setting of type float to a string

◆ MapSettingIntToString

const Settings::SettingIntToStringMap skr::fps2::Settings::MapSettingIntToString
staticprivate
Initial value:
=
{
{SettingUInt32t::SCR_WIDTH, "scr_width"},
{SettingUInt32t::SCR_HEIGHT, "scr_height"},
{SettingUInt32t::RNG_MODE, "rng_mode"},
{SettingUInt32t::RNG_SEED, "rng_seed"},
}

mapping table for settings of type unsigned integer to a string

◆ MapStringToSettingBool

const Settings::StringToSettinBoolMap skr::fps2::Settings::MapStringToSettingBool
staticprivate
Initial value:
=
{
{"rnd_vsync", SettingBool::RND_VSYNC},
{"rng_printseed", SettingBool::RNG_PRINTSEED},
{"rnd_gammacorrection", SettingBool::RND_GAMMACORRECTION},
{"rnd_colorcoderooms", SettingBool::RND_COLORCODEDROOMS}
}

mapping table from a string to a setting of type boolean

◆ MapStringToSettingFloat

const Settings::StringToSettingFloatMap skr::fps2::Settings::MapStringToSettingFloat
staticprivate
Initial value:
=
{
{"rnd_near", SettingFloat::RND_NEAR},
{"rnd_far", SettingFloat::RND_FAR},
}

mapping table from a string to setting of type float

◆ MapStringToSettingInt

const Settings::StringToSettingIntMap skr::fps2::Settings::MapStringToSettingInt
staticprivate
Initial value:
=
{
{"scr_width", SettingUInt32t::SCR_WIDTH},
{"scr_height", SettingUInt32t::SCR_HEIGHT},
{"rng_mode", SettingUInt32t::RNG_MODE},
{"rng_seed", SettingUInt32t::RNG_SEED},
}

mapping table for string to setting of type unsinged integer


The documentation for this class was generated from the following files:
skr::fps2::Settings::SettingBool::RND_GAMMACORRECTION
@ RND_GAMMACORRECTION
use gamma correction of/off
skr::fps2::Settings::SettingBool::RNG_PRINTSEED
@ RNG_PRINTSEED
print seed to cmd and log on/off
skr::fps2::Settings::SettingFloat::RND_NEAR
@ RND_NEAR
distance of near plane
skr::fps2::Settings::RuntimeBoolSetting::GhostMode
@ GhostMode
flag indicating if ghost mode is active (no collision + fly)
skr::fps2::Settings::SettingUInt32t::SCR_WIDTH
@ SCR_WIDTH
viewport width
skr::fps2::Settings::SettingUInt32t::RNG_MODE
@ RNG_MODE
mode of procedural generation
skr::fps2::Settings::RuntimeBoolSetting::UseNormalMapping
@ UseNormalMapping
flag indicating if normal mapping is active
skr::fps2::Settings::SettingBool::RND_VSYNC
@ RND_VSYNC
vertical synchronization on/off
skr::fps2::Settings::RuntimeBoolSetting::MoveLights
@ MoveLights
flag indicating if lights are moving or static
skr::fps2::Settings::SettingUInt32t::SCR_HEIGHT
@ SCR_HEIGHT
viewport height
skr::fps2::Settings::RuntimeBoolSetting::DrawBoundingBox
@ DrawBoundingBox
flag indicating if bounding boxes of geometry are draw
skr::fps2::Settings::RuntimeBoolSetting::DrawDebugLight
@ DrawDebugLight
flag indicating to draw a cube at position of every light
skr::fps2::Settings::SettingBool::RND_COLORCODEDROOMS
@ RND_COLORCODEDROOMS
color code rooms on/off
skr::fps2::Settings::SettingUInt32t::RNG_SEED
@ RNG_SEED
seed for random number generator used in procedural generation
skr::fps2::Settings::SettingFloat::RND_FAR
@ RND_FAR
distance of far plane