Skip to content
Snippets Groups Projects
Commit afd219d4 authored by thebagleboy's avatar thebagleboy
Browse files

Implemented method for listing save files

parent aba960ff
Branches
No related merge requests found
......@@ -72,3 +72,6 @@ ehthumbs.db
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Game-Specific Files and Directories
saves/
#ifndef MAIN_H
#define MAIN_H
#include <iostream>
#include "save-manager.h"
#endif // MAIN_H
#ifndef SAVEMANAGER_H
#define SAVEMANAGER_H
#include <string>
#include <iostream>
#include <filesystem>
#include <vector>
class SaveManager
{
public:
SaveManager();
~SaveManager();
bool save();
bool load();
void list();
private:
const std::string SAVE_LOCATION = "saves";
void findSaves();
std::vector< std::string > saves;
};
#endif // SAVEMANAGER_H
......@@ -4,7 +4,7 @@
CXX = g++
# Compiler flags
CXXFLAGS = -std=c++11 -Wall
CXXFLAGS = -std=c++17 -Wall
# Source directory
SRC_DIR = src
......
#include <iostream>
#include "main.h"
int main() {
std::cout << "Hello, World!" << std::endl;
// Initialise
bool isRunning = true;
int tickCount = 0;
SaveManager saveManager;
// Menu Loop
// List Saves
saveManager.list();
// Main Loop
while( isRunning )
{
if( ++tickCount > 1000 )
{
// Exit
isRunning = false;
}
// Process Input
// Update Game State
// Render Game
}
// Clean-up
// Return
std::cout << "Process Ending" << std::endl;
return 0;
}
#include "save-manager.h"
SaveManager::SaveManager()
{
std::cout << "Save Manager Created" << std::endl;
this->findSaves();
}
SaveManager::~SaveManager()
{
std::cout << "Save Manager Deleted" << std::endl;
}
bool SaveManager::save(){ return true; }
bool SaveManager::load(){ return true; }
void SaveManager::findSaves()
{
std::vector<std::string> saves;
if( ! std::filesystem::is_directory( SAVE_LOCATION ) )
{
return;
}
for( const auto& entry : std::filesystem::directory_iterator( SAVE_LOCATION ) )
{
saves.push_back( entry.path().filename() );
}
this->saves = saves;
}
void SaveManager::list()
{
for( const std::string& save : this->saves )
{
std::cout << "Save: " << save << std::endl;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment