PRooFPS-dd Dev Doc 1.0
PRooFPS-dd Developer Documentation
Loading...
Searching...
No Matches
proofps_dd::Mapcycle Class Reference

Detailed Description

Definition at line 20 of file Mapcycle.h.

#include <Mapcycle.h>

+ Inheritance diagram for proofps_dd::Mapcycle:

Public Member Functions

CConsole & getConsole () const
 
 Mapcycle ()
 
 ~Mapcycle ()
 
 Mapcycle (const Mapcycle &)=delete
 
Mapcycleoperator= (const Mapcycle &)=delete
 
 Mapcycle (Mapcycle &&)=delete
 
Mapcycle && operator= (Mapcycle &&)=delete
 
bool initialize ()
 Updates list of available maps and mapcycle content.
 
bool isInitialized () const
 
void shutdown ()
 Releases any allocated resources related to available maps list and mapcycle.
 
const std::set< std::string > & availableMapsGet () const
 
const std::string & availableMapsGetElem (const size_t &index) const
 
const char ** availableMapsGetAsCharPtrArray () const
 This is convenience function to be used with GUI: Dear ImGUI requires this kind of array as source of items of Listbox.
 
const std::set< std::string > & availableMapsNoChangingGet () const
 
const std::string & availableMapsNoChangingGetElem (const size_t &index) const
 
const std::vector< std::string > & mapcycleGet () const
 
const char ** mapcycleGetAsCharPtrArray () const
 This is convenience function to be used with GUI: Dear ImGUI requires this kind of array as source of items of Listbox.
 
std::string mapcycleGetCurrent () const
 
bool mapcycleIsCurrentLast () const
 
std::string mapcycleNext ()
 
std::string mapcycleRewindToFirst ()
 
std::string mapcycleForwardToLast ()
 
bool mapcycleSaveToFile ()
 
void mapcycle_availableMaps_Synchronize ()
 This one is recommended during initialization, since it reloads both the mapcycle and available maps list, and makes sure they become disjoint sets.
 
bool mapcycleAdd_availableMapsRemove (const std::string &sMapFilename)
 
bool mapcycleAdd_availableMapsRemove (const std::vector< std::string > &vMapFilenames)
 
bool mapcycleAdd_availableMapsRemove ()
 
bool mapcycleRemove_availableMapsAdd (const std::string &sMapFilename)
 
bool mapcycleRemove_availableMapsAdd (const size_t &indexToMapcycle)
 
bool mapcycleRemove_availableMapsAdd (const std::vector< std::string > &vMapFilenames)
 
bool mapcycleRemove_availableMapsAdd ()
 

Static Public Member Functions

static const char * getLoggerModuleName ()
 
static bool isValidMapFilename (const std::string &sFilename)
 

Static Public Attributes

static constexpr char * GAME_MAPS_DIR = "gamedata/maps/"
 

Protected Member Functions

void availableMapsRefresh ()
 
bool availableMapsAdd (const std::string &sMapFilename)
 
bool availableMapsAdd (const std::vector< std::string > &vMapFilenames)
 
bool availableMapsRemove (const std::string &sMapFilename)
 
bool availableMapsRemove (const size_t &index)
 
bool availableMapsRemove (const std::vector< std::string > &vMapFilenames)
 
bool mapcycleReload ()
 
bool mapcycleAdd (const std::string &sMapFilename)
 
bool mapcycleAdd (const std::vector< std::string > &vMapFilenames)
 
bool mapcycleAdd (const std::set< std::string > &vMapFilenames)
 
bool mapcycleRemove (const std::string &sMapFilename)
 
bool mapcycleRemove (const size_t &index)
 
bool mapcycleRemove (const std::vector< std::string > &vMapFilenames)
 
void mapcycleClear ()
 
size_t mapcycleRemoveNonExisting ()
 Removes items from mapcycle that are referring to non-existing files in the current filesystem.
 

Private Member Functions

bool mapFilenameAddToVector_NoDuplicatesAllowed (const std::string &sMapFilename, std::vector< std::string > &vec)
 
bool mapFilenameAddToSet_NoDuplicatesAllowed (const std::string &sMapFilename, std::set< std::string > &settt)
 
bool mapFilenameRemoveFromVector (const std::string &sMapFilename, std::vector< std::string > &vec)
 
bool mapFilenameRemoveFromSet (const std::string &sMapFilename, std::set< std::string > &settt)
 
void availableMapsRefreshCharPtrArray ()
 
void mapcycleRefreshCharPtrArray ()
 

Static Private Member Functions

static bool lineShouldBeIgnored (const std::string &sLine)
 

Private Attributes

bool m_bInitialized = false
 
std::set< std::string > m_availableMaps
 
const char ** m_vszAvailableMaps = nullptr
 
std::set< std::string > m_availableMapsNoChanging
 
std::string m_sEmptyStringToReturn
 
std::vector< std::string > m_mapcycle
 
std::vector< std::string >::iterator m_mapcycleItCurrent = m_mapcycle.end()
 
const char ** m_vszMapcycle = nullptr
 

Constructor & Destructor Documentation

◆ Mapcycle() [1/3]

proofps_dd::Mapcycle::Mapcycle ( )

Definition at line 24 of file Mapcycle.cpp.

◆ ~Mapcycle()

proofps_dd::Mapcycle::~Mapcycle ( )

Definition at line 28 of file Mapcycle.cpp.

◆ Mapcycle() [2/3]

proofps_dd::Mapcycle::Mapcycle ( const Mapcycle & )
delete

◆ Mapcycle() [3/3]

proofps_dd::Mapcycle::Mapcycle ( Mapcycle && )
delete

Member Function Documentation

◆ availableMapsAdd() [1/2]

bool proofps_dd::Mapcycle::availableMapsAdd ( const std::string & sMapFilename)
protected

Definition at line 444 of file Mapcycle.cpp.

◆ availableMapsAdd() [2/2]

bool proofps_dd::Mapcycle::availableMapsAdd ( const std::vector< std::string > & vMapFilenames)
protected

Definition at line 453 of file Mapcycle.cpp.

◆ availableMapsGet()

const std::set< std::string > & proofps_dd::Mapcycle::availableMapsGet ( ) const

Definition at line 119 of file Mapcycle.cpp.

◆ availableMapsGetAsCharPtrArray()

const char ** proofps_dd::Mapcycle::availableMapsGetAsCharPtrArray ( ) const

This is convenience function to be used with GUI: Dear ImGUI requires this kind of array as source of items of Listbox.

It is better if Maps provide it so we can avoid inconsistency. The elements are the same as in the availableMapsGet() container.

Returns
A char array with same size as the availableMapsGet() container, where all elements point to the corresponding null-terminated string of the string object of the availableMapsGet() container. Null when size of availableMapsGet() container is 0.

Definition at line 146 of file Mapcycle.cpp.

◆ availableMapsGetElem()

const std::string & proofps_dd::Mapcycle::availableMapsGetElem ( const size_t & index) const

Definition at line 124 of file Mapcycle.cpp.

◆ availableMapsNoChangingGet()

const std::set< std::string > & proofps_dd::Mapcycle::availableMapsNoChangingGet ( ) const

Definition at line 151 of file Mapcycle.cpp.

◆ availableMapsNoChangingGetElem()

const std::string & proofps_dd::Mapcycle::availableMapsNoChangingGetElem ( const size_t & index) const

Definition at line 156 of file Mapcycle.cpp.

◆ availableMapsRefresh()

void proofps_dd::Mapcycle::availableMapsRefresh ( )
protected

Definition at line 421 of file Mapcycle.cpp.

◆ availableMapsRefreshCharPtrArray()

void proofps_dd::Mapcycle::availableMapsRefreshCharPtrArray ( )
private

Definition at line 812 of file Mapcycle.cpp.

◆ availableMapsRemove() [1/3]

bool proofps_dd::Mapcycle::availableMapsRemove ( const size_t & index)
protected

Definition at line 481 of file Mapcycle.cpp.

◆ availableMapsRemove() [2/3]

bool proofps_dd::Mapcycle::availableMapsRemove ( const std::string & sMapFilename)
protected

Definition at line 472 of file Mapcycle.cpp.

◆ availableMapsRemove() [3/3]

bool proofps_dd::Mapcycle::availableMapsRemove ( const std::vector< std::string > & vMapFilenames)
protected

Definition at line 501 of file Mapcycle.cpp.

◆ getConsole()

CConsole & proofps_dd::Mapcycle::getConsole ( ) const

Definition at line 38 of file Mapcycle.cpp.

◆ getLoggerModuleName()

const char * proofps_dd::Mapcycle::getLoggerModuleName ( )
static

Definition at line 33 of file Mapcycle.cpp.

◆ initialize()

bool proofps_dd::Mapcycle::initialize ( )

Updates list of available maps and mapcycle content.

Returns
True on success, false otherwise.

Definition at line 76 of file Mapcycle.cpp.

◆ isInitialized()

bool proofps_dd::Mapcycle::isInitialized ( ) const

Definition at line 91 of file Mapcycle.cpp.

◆ isValidMapFilename()

bool proofps_dd::Mapcycle::isValidMapFilename ( const std::string & sFilename)
static

Definition at line 43 of file Mapcycle.cpp.

◆ lineShouldBeIgnored()

bool proofps_dd::Mapcycle::lineShouldBeIgnored ( const std::string & sLine)
staticprivate

Definition at line 733 of file Mapcycle.cpp.

◆ mapcycle_availableMaps_Synchronize()

void proofps_dd::Mapcycle::mapcycle_availableMaps_Synchronize ( )

This one is recommended during initialization, since it reloads both the mapcycle and available maps list, and makes sure they become disjoint sets.

Definition at line 278 of file Mapcycle.cpp.

◆ mapcycleAdd() [1/3]

bool proofps_dd::Mapcycle::mapcycleAdd ( const std::set< std::string > & vMapFilenames)
protected

Definition at line 611 of file Mapcycle.cpp.

◆ mapcycleAdd() [2/3]

bool proofps_dd::Mapcycle::mapcycleAdd ( const std::string & sMapFilename)
protected

Definition at line 580 of file Mapcycle.cpp.

◆ mapcycleAdd() [3/3]

bool proofps_dd::Mapcycle::mapcycleAdd ( const std::vector< std::string > & vMapFilenames)
protected

Definition at line 590 of file Mapcycle.cpp.

◆ mapcycleAdd_availableMapsRemove() [1/3]

bool proofps_dd::Mapcycle::mapcycleAdd_availableMapsRemove ( )

Definition at line 326 of file Mapcycle.cpp.

◆ mapcycleAdd_availableMapsRemove() [2/3]

bool proofps_dd::Mapcycle::mapcycleAdd_availableMapsRemove ( const std::string & sMapFilename)

Definition at line 288 of file Mapcycle.cpp.

◆ mapcycleAdd_availableMapsRemove() [3/3]

bool proofps_dd::Mapcycle::mapcycleAdd_availableMapsRemove ( const std::vector< std::string > & vMapFilenames)

Definition at line 307 of file Mapcycle.cpp.

◆ mapcycleClear()

void proofps_dd::Mapcycle::mapcycleClear ( )
protected

Definition at line 679 of file Mapcycle.cpp.

◆ mapcycleForwardToLast()

std::string proofps_dd::Mapcycle::mapcycleForwardToLast ( )

Definition at line 261 of file Mapcycle.cpp.

◆ mapcycleGet()

const std::vector< std::string > & proofps_dd::Mapcycle::mapcycleGet ( ) const

Definition at line 169 of file Mapcycle.cpp.

◆ mapcycleGetAsCharPtrArray()

const char ** proofps_dd::Mapcycle::mapcycleGetAsCharPtrArray ( ) const

This is convenience function to be used with GUI: Dear ImGUI requires this kind of array as source of items of Listbox.

It is better if Maps provide it so we can avoid inconsistency. The elements are the same as in the mapcycleGet() container.

Returns
A char array with same size as the mapcycleGet() container, where all elements point to the corresponding null-terminated string of the string object of the mapcycleGet() container. Null when size of mapcycleGet() container is 0.

Definition at line 183 of file Mapcycle.cpp.

◆ mapcycleGetCurrent()

std::string proofps_dd::Mapcycle::mapcycleGetCurrent ( ) const

Definition at line 188 of file Mapcycle.cpp.

◆ mapcycleIsCurrentLast()

bool proofps_dd::Mapcycle::mapcycleIsCurrentLast ( ) const

Definition at line 195 of file Mapcycle.cpp.

◆ mapcycleNext()

std::string proofps_dd::Mapcycle::mapcycleNext ( )

Definition at line 233 of file Mapcycle.cpp.

◆ mapcycleRefreshCharPtrArray()

void proofps_dd::Mapcycle::mapcycleRefreshCharPtrArray ( )
private

Definition at line 830 of file Mapcycle.cpp.

◆ mapcycleReload()

bool proofps_dd::Mapcycle::mapcycleReload ( )
protected

Definition at line 520 of file Mapcycle.cpp.

◆ mapcycleRemove() [1/3]

bool proofps_dd::Mapcycle::mapcycleRemove ( const size_t & index)
protected

Definition at line 642 of file Mapcycle.cpp.

◆ mapcycleRemove() [2/3]

bool proofps_dd::Mapcycle::mapcycleRemove ( const std::string & sMapFilename)
protected

Definition at line 632 of file Mapcycle.cpp.

◆ mapcycleRemove() [3/3]

bool proofps_dd::Mapcycle::mapcycleRemove ( const std::vector< std::string > & vMapFilenames)
protected

Definition at line 658 of file Mapcycle.cpp.

◆ mapcycleRemove_availableMapsAdd() [1/4]

bool proofps_dd::Mapcycle::mapcycleRemove_availableMapsAdd ( )

Definition at line 400 of file Mapcycle.cpp.

◆ mapcycleRemove_availableMapsAdd() [2/4]

bool proofps_dd::Mapcycle::mapcycleRemove_availableMapsAdd ( const size_t & indexToMapcycle)

Definition at line 361 of file Mapcycle.cpp.

◆ mapcycleRemove_availableMapsAdd() [3/4]

bool proofps_dd::Mapcycle::mapcycleRemove_availableMapsAdd ( const std::string & sMapFilename)

Definition at line 342 of file Mapcycle.cpp.

◆ mapcycleRemove_availableMapsAdd() [4/4]

bool proofps_dd::Mapcycle::mapcycleRemove_availableMapsAdd ( const std::vector< std::string > & vMapFilenames)

Definition at line 381 of file Mapcycle.cpp.

◆ mapcycleRemoveNonExisting()

size_t proofps_dd::Mapcycle::mapcycleRemoveNonExisting ( )
protected

Removes items from mapcycle that are referring to non-existing files in the current filesystem.

It can happen that someone manually edits the mapcycle file, or someone copies another mapcycle file over our file, leading to having entries that are invalid in the current filesystem. So this function is making sure the mapcycle is valid.

It uses availableMaps so it is recommended to invoke availableMapsRefresh() first! Make sure you never invoke this function without calling availableMapsRefresh() first, otherwise even the on-disk mapcycle items will be also removed from mapcycle.

Returns
The number of removed items.

Definition at line 701 of file Mapcycle.cpp.

◆ mapcycleRewindToFirst()

std::string proofps_dd::Mapcycle::mapcycleRewindToFirst ( )

Definition at line 250 of file Mapcycle.cpp.

◆ mapcycleSaveToFile()

bool proofps_dd::Mapcycle::mapcycleSaveToFile ( )

Definition at line 200 of file Mapcycle.cpp.

◆ mapFilenameAddToSet_NoDuplicatesAllowed()

bool proofps_dd::Mapcycle::mapFilenameAddToSet_NoDuplicatesAllowed ( const std::string & sMapFilename,
std::set< std::string > & settt )
private

Definition at line 757 of file Mapcycle.cpp.

◆ mapFilenameAddToVector_NoDuplicatesAllowed()

bool proofps_dd::Mapcycle::mapFilenameAddToVector_NoDuplicatesAllowed ( const std::string & sMapFilename,
std::vector< std::string > & vec )
private

Definition at line 738 of file Mapcycle.cpp.

◆ mapFilenameRemoveFromSet()

bool proofps_dd::Mapcycle::mapFilenameRemoveFromSet ( const std::string & sMapFilename,
std::set< std::string > & settt )
private

Definition at line 795 of file Mapcycle.cpp.

◆ mapFilenameRemoveFromVector()

bool proofps_dd::Mapcycle::mapFilenameRemoveFromVector ( const std::string & sMapFilename,
std::vector< std::string > & vec )
private

Definition at line 776 of file Mapcycle.cpp.

◆ operator=() [1/2]

Mapcycle & proofps_dd::Mapcycle::operator= ( const Mapcycle & )
delete

◆ operator=() [2/2]

Mapcycle && proofps_dd::Mapcycle::operator= ( Mapcycle && )
delete

◆ shutdown()

void proofps_dd::Mapcycle::shutdown ( )

Releases any allocated resources related to available maps list and mapcycle.

After calling this, initialize() can be invoked again.

Definition at line 100 of file Mapcycle.cpp.

Member Data Documentation

◆ GAME_MAPS_DIR

char* proofps_dd::Mapcycle::GAME_MAPS_DIR = "gamedata/maps/"
staticconstexpr

Definition at line 24 of file Mapcycle.h.

◆ m_availableMaps

std::set<std::string> proofps_dd::Mapcycle::m_availableMaps
private

Definition at line 110 of file Mapcycle.h.

◆ m_availableMapsNoChanging

std::set<std::string> proofps_dd::Mapcycle::m_availableMapsNoChanging
private

Definition at line 113 of file Mapcycle.h.

◆ m_bInitialized

bool proofps_dd::Mapcycle::m_bInitialized = false
private

Definition at line 106 of file Mapcycle.h.

◆ m_mapcycle

std::vector<std::string> proofps_dd::Mapcycle::m_mapcycle
private

Definition at line 122 of file Mapcycle.h.

◆ m_mapcycleItCurrent

std::vector<std::string>::iterator proofps_dd::Mapcycle::m_mapcycleItCurrent = m_mapcycle.end()
private

Definition at line 123 of file Mapcycle.h.

◆ m_sEmptyStringToReturn

std::string proofps_dd::Mapcycle::m_sEmptyStringToReturn
private

Definition at line 114 of file Mapcycle.h.

◆ m_vszAvailableMaps

const char** proofps_dd::Mapcycle::m_vszAvailableMaps = nullptr
private

Definition at line 111 of file Mapcycle.h.

◆ m_vszMapcycle

const char** proofps_dd::Mapcycle::m_vszMapcycle = nullptr
private

Definition at line 124 of file Mapcycle.h.


The documentation for this class was generated from the following files: