Skip to content
This repository was archived by the owner on Apr 20, 2022. It is now read-only.

Commit 8c506df

Browse files
committed
Another big change set. I refrain from using the term "doozy" each time it gets this big.
Started implementing an API layer, currently only adding, clearing, saving, and loading factions is supported. Pulled the relevant startup code out of the console driver and into the API. Restructued some of the code. Gto rid of the ConfigManager class and library, making Config loading handled by the API layer on startup. Moved third-party header-only libraries to the top-level include folder (only the Catch header and spdlog libs currently). Added the spdlog logging library.
1 parent 8cf85be commit 8c506df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+12134
-207
lines changed

.vscode/c_cpp_properties.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,16 @@
3434
"/usr/lib/gcc/x86_64-pc-linux-gnu/7.2.0/include-fixed",
3535
"/usr/include",
3636
"${workspaceRoot}",
37-
"${workspaceRoot}/Configuration/include",
37+
"${workspaceRoot}/include",
3838
"${workspaceRoot}/DataAccess/include",
3939
"${workspaceRoot}/DiceRoll/include",
4040
"${workspaceRoot}/FactionControl/include",
4141
"${workspaceRoot}/HexGrid/include",
4242
"${workspaceRoot}/Models/include",
4343
"${workspaceRoot}/SectorGen/include",
44-
"${workspaceRoot}/SGT/include"
44+
"${workspaceRoot}/SwnGmToolAPI/include",
45+
"${workspaceRoot}/Driver/include",
46+
"${workspaceRoot}/Tests/include"
4547
],
4648
"defines": [],
4749
"intelliSenseMode": "clang-x64",

CMakeLists.txt

+9-8
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O2")
99
option(BUILD_DRIVER "Build driver" ON)
1010
option(BUILD_TESTS "Build tests" ON)
1111

12-
# Configuration lib
13-
include_directories(${PROJECT_SOURCE_DIR}/Configuration/include)
14-
add_subdirectory(Configuration)
15-
1612
# Data Access lib
1713
include_directories(${PROJECT_SOURCE_DIR}/DataAccess/include)
1814
add_subdirectory(DataAccess)
@@ -36,9 +32,13 @@ include_directories(${PROJECT_SOURCE_DIR}/Models/include)
3632
include_directories(${PROJECT_SOURCE_DIR}/SectorGen/include)
3733
add_subdirectory(SectorGen)
3834

39-
# SGT (Driver)
40-
include_directories(${PROJECT_SOURCE_DIR}/SGT/include)
41-
add_subdirectory(SGT)
35+
# SwnGmToolAPI
36+
include_directories(${PROJECT_SOURCE_DIR}/SwnGmToolAPI/include)
37+
add_subdirectory(SwnGmToolAPI)
38+
39+
# Driver
40+
include_directories(${PROJECT_SOURCE_DIR}/Driver/include)
41+
add_subdirectory(Driver)
4242

4343
# Tests
4444
if(BUILD_TESTS)
@@ -47,7 +47,8 @@ endif(BUILD_TESTS)
4747

4848
if(BUILD_DRIVER)
4949
# Add all extra libs
50-
set(EXTRA_LIBS ${EXTRA_LIBS} Configuration DataAccess DiceRoll HexGrid FactionControl SectorGen SGT)
50+
set(EXTRA_LIBS ${EXTRA_LIBS} DataAccess DiceRoll HexGrid FactionControl SectorGen SwnGmToolAPI Driver)
51+
set(EXTRA_LIBS ${EXTRA_LIBS} pthread)
5152

5253
include_directories(${PROJECT_SOURCE_DIR}/include)
5354
set(SOURCES main.cpp)

Configuration/CMakeLists.txt

-5
This file was deleted.

Configuration/include/ConfigManager.hpp

-24
This file was deleted.

Configuration/src/ConfigManager.cpp

-50
This file was deleted.

DataAccess/include/FileAccess.hpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include <cereal/archives/json.hpp>
1111

1212
#include <fmt/format.h>
13-
#include <fmt/printf.h>
1413

1514
namespace SwnGmTool
1615
{
@@ -30,7 +29,7 @@ namespace SwnGmTool
3029
}
3130
catch(cereal::RapidJSONException ex)
3231
{
33-
fmt::printf("Error saving: {0}\n", ex.what() );
32+
//fmt::printf("Error saving: {0}\n", ex.what() );
3433
throw(ex);
3534
}
3635
}
@@ -45,7 +44,7 @@ namespace SwnGmTool
4544
}
4645
catch(cereal::RapidJSONException ex)
4746
{
48-
fmt::printf("Error loading: {0}\n", ex.what() );
47+
//fmt::printf("Error loading: {0}\n", ex.what() );
4948
throw(ex);
5049
}
5150
}

Driver/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include_directories(${PROJECT_SOURCE_DIR}/include)
2+
3+
set(SOURCES src/Driver.cpp)
4+
5+
add_library(Driver SHARED ${SOURCES})

Driver/include/Driver.hpp

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#ifndef DRIVER_HPP
2+
#define DRIVER_HPP
3+
4+
#include <iostream>
5+
#include <memory>
6+
#include <vector>
7+
8+
#include "spdlog/spdlog.h"
9+
10+
#include "MenuOptions.hpp"
11+
#include "SwnGmToolAPI.hpp"
12+
13+
namespace Driver
14+
{
15+
class Driver
16+
{
17+
public:
18+
Driver();
19+
20+
bool Init();
21+
void Run();
22+
23+
void PrintMenu(const std::vector<MenuOption>&);
24+
void PrintMainMenu();
25+
void PrintFactionMenu();
26+
27+
void GetMainMenuInput(std::istream& = std::cin);
28+
void GetFactionControlInput(std::istream& = std::cin);
29+
30+
void RunFactionControl();
31+
void ShowFactionList();
32+
void AddFaction(std::istream& = std::cin);
33+
void RemoveFaction(std::istream& = std::cin);
34+
void ClearFactionlist();
35+
36+
void RunAssetControl();
37+
void AddAsset();
38+
void RemoveAsset();
39+
void RemoveAllAssetsOfType();
40+
void ClearAssetList();
41+
42+
void Save(std::ostream& = std::cout);
43+
void Load(std::istream& in = std::cin);
44+
45+
private:
46+
std::shared_ptr<spdlog::logger> _clogger;
47+
std::unique_ptr<SwnGmTool::SwnGmToolAPI> SGTAPI;
48+
49+
bool IsRunning;
50+
bool IsRunningFC;
51+
bool IsRunningAC;
52+
};
53+
}
54+
55+
#endif

SGT/include/MenuOptions.hpp renamed to Driver/include/MenuOptions.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Driver
1515
const std::vector<MenuOption> MainMenuOptions
1616
{
1717
{ '1', "Manage Factions" },
18-
//{ '2', "Manage Sector" },
18+
{ '2', "Manage Sector" },
1919
{ 'Q', "Quit" }
2020
};
2121

0 commit comments

Comments
 (0)