Skip to content

Commit

Permalink
Replaced VersionParser with commonItems::ConverterVersionParser (#155)…
Browse files Browse the repository at this point in the history
… #patch
  • Loading branch information
IhateTrains authored Mar 10, 2021
1 parent 9cb2dbe commit 07c092b
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 183 deletions.
3 changes: 1 addition & 2 deletions ImperatorToCK3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.5)
#set(CMAKE_VERBOSE_MAKEFILE on)

project(ImperatorToCK3)
#SET(CMAKE_CXX_COMPILER g++-9)
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/Source)
set(PROJECT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/Source)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/Release-Linux)
Expand All @@ -15,7 +14,6 @@ add_compile_options("-pthread")
add_link_options(-no-pie)

include_directories("../commonItems")
include_directories("../commonItems/compile-time-regular-expressions/single-header")
include_directories("../ZipLib")
include_directories("/usr/local/include/ImageMagick-7/")
include_directories("../cpp-base64")
Expand All @@ -34,6 +32,7 @@ file(GLOB CK3OUTPUTTER_SOURCES "${PROJECT_SOURCE_DIR}/CK3Outputter/*.cpp")
set(BASE64_SOURCES "../cpp-base64/base64.cpp")
set(COMMON_SOURCES "../commonItems/CommonFunctions.cpp")
set(COMMON_SOURCES ${COMMON_SOURCES} "../commonItems/Color.cpp")
set(COMMON_SOURCES ${COMMON_SOURCES} "../commonItems/ConverterVersion.cpp")
set(COMMON_SOURCES ${COMMON_SOURCES} "../commonItems/GameVersion.cpp")
set(COMMON_SOURCES ${COMMON_SOURCES} "../commonItems/Date.cpp")
set(COMMON_SOURCES ${COMMON_SOURCES} "../commonItems/LinuxUtils.cpp")
Expand Down
4 changes: 2 additions & 2 deletions ImperatorToCK3/ImperatorToCK3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
<ClCompile Include="..\commonItems\Color.cpp" />
<ClCompile Include="..\commonItems\CommonFunctions.cpp" />
<ClCompile Include="..\commonItems\ConvenientParser.cpp" />
<ClCompile Include="..\commonItems\ConverterVersion.cpp" />
<ClCompile Include="..\commonItems\Date.cpp" />
<ClCompile Include="..\commonItems\GameVersion.cpp" />
<ClCompile Include="..\commonItems\iconvlite.cpp" />
Expand Down Expand Up @@ -304,13 +305,13 @@
<ClCompile Include="Source\Mappers\TagTitleMapper\TagTitleMapping.cpp" />
<ClCompile Include="Source\Mappers\TraitMapper\TraitMapper.cpp" />
<ClCompile Include="Source\Mappers\TraitMapper\TraitMapping.cpp" />
<ClCompile Include="Source\Mappers\VersionParser\VersionParser.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\commonItems\Color.h" />
<ClInclude Include="..\commonItems\CommonFunctions.h" />
<ClInclude Include="..\commonItems\CommonRegexes.h" />
<ClInclude Include="..\commonItems\ConvenientParser.h" />
<ClInclude Include="..\commonItems\ConverterVersion.h" />
<ClInclude Include="..\commonItems\Date.h" />
<ClInclude Include="..\commonItems\GameVersion.h" />
<ClInclude Include="..\commonItems\iconvlite.h" />
Expand Down Expand Up @@ -402,7 +403,6 @@
<ClInclude Include="Source\Mappers\TagTitleMapper\TagTitleMapping.h" />
<ClInclude Include="Source\Mappers\TraitMapper\TraitMapper.h" />
<ClInclude Include="Source\Mappers\TraitMapper\TraitMapping.h" />
<ClInclude Include="Source\Mappers\VersionParser\VersionParser.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ZipLib\ZipLib.vcxproj">
Expand Down
15 changes: 6 additions & 9 deletions ImperatorToCK3/ImperatorToCK3.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@
<Filter Include="Mappers\NicknameMapper">
<UniqueIdentifier>{2404ac05-3984-4e42-9e9d-b039e3d69238}</UniqueIdentifier>
</Filter>
<Filter Include="Mappers\VersionParser">
<UniqueIdentifier>{0bd26324-6936-4f56-825a-3e90efa339df}</UniqueIdentifier>
</Filter>
<Filter Include="Mappers\ImperatorRegionMapper">
<UniqueIdentifier>{f9b0565f-9991-465b-8df3-67bdce281de6}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -331,9 +328,6 @@
<ClInclude Include="Source\Mappers\NicknameMapper\NicknameMapping.h">
<Filter>Mappers\NicknameMapper</Filter>
</ClInclude>
<ClInclude Include="Source\Mappers\VersionParser\VersionParser.h">
<Filter>Mappers\VersionParser</Filter>
</ClInclude>
<ClInclude Include="Source\Mappers\RegionMapper\CK3RegionMapper.h">
<Filter>Mappers\CK3RegionMapper</Filter>
</ClInclude>
Expand Down Expand Up @@ -397,6 +391,9 @@
<ClInclude Include="Source\Mappers\SuccessionLawMapper\SuccessionLawMapping.h">
<Filter>Mappers\SuccessionLawMapper</Filter>
</ClInclude>
<ClInclude Include="..\commonItems\ConverterVersion.h">
<Filter>commonItems</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Source\main.cpp" />
Expand Down Expand Up @@ -608,9 +605,6 @@
<ClCompile Include="Source\Mappers\NicknameMapper\NicknameMapping.cpp">
<Filter>Mappers\NicknameMapper</Filter>
</ClCompile>
<ClCompile Include="Source\Mappers\VersionParser\VersionParser.cpp">
<Filter>Mappers\VersionParser</Filter>
</ClCompile>
<ClCompile Include="Source\Mappers\RegionMapper\CK3RegionMapper.cpp">
<Filter>Mappers\CK3RegionMapper</Filter>
</ClCompile>
Expand Down Expand Up @@ -677,6 +671,9 @@
<ClCompile Include="Source\Mappers\SuccessionLawMapper\SuccessionLawMapping.cpp">
<Filter>Mappers\SuccessionLawMapper</Filter>
</ClCompile>
<ClCompile Include="..\commonItems\ConverterVersion.cpp">
<Filter>commonItems</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="Resources\rakaly.dll">
Expand Down
3 changes: 2 additions & 1 deletion ImperatorToCK3/Source/CK3/CK3World.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Titles/Title.h"
#include "Log.h"
#include "OSCompatibilityLayer.h"
#include "ConverterVersion.h"
#include <filesystem>
#include <fstream>
#include <cmath>
Expand All @@ -19,7 +20,7 @@ namespace fs = std::filesystem;



CK3::World::World(const Imperator::World& impWorld, const Configuration& theConfiguration, const mappers::VersionParser& versionParser) {
CK3::World::World(const Imperator::World& impWorld, const Configuration& theConfiguration, const commonItems::ConverterVersion& converterVersion) {
LOG(LogLevel::Info) << "*** Hello CK3, let's get painting. ***";
// Scraping localizations from Imperator so we may know proper names for our countries.
localizationMapper.scrapeLocalizations(theConfiguration, std::map<std::string, std::string>()); // passes an empty map as second arg because we don't actually load mods yet
Expand Down
7 changes: 5 additions & 2 deletions ImperatorToCK3/Source/CK3/CK3World.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@



#include "Mappers/VersionParser/VersionParser.h"
#include "Mappers/LocalizationMapper/LocalizationMapper.h"
#include "Mappers/TagTitleMapper/TagTitleMapper.h"
#include "Mappers/CultureMapper/CultureMapper.h"
Expand Down Expand Up @@ -31,11 +30,15 @@ namespace Imperator {
class World;
}

namespace commonItems {
struct ConverterVersion;
}

namespace CK3 {

class World {
public:
World(const Imperator::World& impWorld, const Configuration& theConfiguration, const mappers::VersionParser& versionParser);
World(const Imperator::World& impWorld, const Configuration& theConfiguration, const commonItems::ConverterVersion& converterVersion);

[[nodiscard]] const auto& getCharacters() const { return characters; }
[[nodiscard]] const auto& getDynasties() const { return dynasties; }
Expand Down
17 changes: 8 additions & 9 deletions ImperatorToCK3/Source/CK3Outputter/outVersion.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#include "outVersion.h"
#include "Mappers/VersionParser/VersionParser.h"
#include "ConverterVersion.h"
#include "Log.h"
#include <fstream>



std::ostream& mappers::operator<<(std::ostream& output, const VersionParser& versionParser) {
void logConverterVersion(const commonItems::ConverterVersion& versionParser) {
// read commit id
std::string commitID;
std::ifstream commitIdFile{ "../commit_id.txt" };
commitIdFile >> commitID;
commitIdFile.close();

output << "\n\n";
output << "************ -= The Paradox Converters Team =- ********************\n";
output << "* Converter build based on commit " << commitID << "\n";
output << "* " << versionParser.descriptionLine << "\n";
output << "* Built on " << __TIMESTAMP__ << "\n";
output << "*********** + Imperator: Rome To Crusader Kings III + **************\n";
return output;
Log(LogLevel::Info) << "************ -= The Paradox Converters Team =- ********************";
Log(LogLevel::Info) << "* Converter build based on commit " << commitID;
Log(LogLevel::Info) << "* " << versionParser.descriptionLine;
Log(LogLevel::Info) << "* Built on " << __TIMESTAMP__;
Log(LogLevel::Info) << "*********** + Imperator: Rome To Crusader Kings III + *************\n";
}
13 changes: 4 additions & 9 deletions ImperatorToCK3/Source/CK3Outputter/outVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@



#include <ostream>
namespace commonItems {
struct ConverterVersion;
} // namespace commonItems



namespace mappers {

class VersionParser;
std::ostream& operator<<(std::ostream& output, const VersionParser& versionParser);

} // namespace mappers
void logConverterVersion(const commonItems::ConverterVersion& versionParser);



Expand Down
8 changes: 5 additions & 3 deletions ImperatorToCK3/Source/ImperatorToCK3Converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
#include "CK3/CK3World.h"
#include "CK3Outputter/CK3WorldOutputter.h"
#include "Log.h"
#include "ConverterVersion.h"

void convertImperatorToCK3(const mappers::VersionParser& versionParser)
{


void convertImperatorToCK3(const commonItems::ConverterVersion& converterVersion) {
const Configuration theConfiguration;

const Imperator::World impWorld(theConfiguration);
const CK3::World ck3World(impWorld, theConfiguration, versionParser);
const CK3::World ck3World(impWorld, theConfiguration, converterVersion);
CK3::outputWorld(ck3World, theConfiguration);

LOG(LogLevel::Info) << "* Conversion complete *";
Expand Down
10 changes: 7 additions & 3 deletions ImperatorToCK3/Source/ImperatorToCK3Converter.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#ifndef IMPERATORTOCK3_CONVERTER_H
#define IMPERATORTOCK3_CONVERTER_H

namespace mappers {
class VersionParser;


namespace commonItems {
struct ConverterVersion;
}

void convertImperatorToCK3(const mappers::VersionParser& versionParser);
void convertImperatorToCK3(const commonItems::ConverterVersion& converterVersion);



#endif // IMPERATORTOCK3_CONVERTER_H
32 changes: 0 additions & 32 deletions ImperatorToCK3/Source/Mappers/VersionParser/VersionParser.cpp

This file was deleted.

34 changes: 0 additions & 34 deletions ImperatorToCK3/Source/Mappers/VersionParser/VersionParser.h

This file was deleted.

17 changes: 11 additions & 6 deletions ImperatorToCK3/Source/main.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
#include "ImperatorToCK3Converter.h"
#include "Mappers/VersionParser/VersionParser.h"
#include "CK3Outputter/outVersion.h"
#include "Log.h"
#include "ConverterVersion.h"
#include <Magick++/Functions.h>

int main(const int argc, const char* argv[])
{


int main(const int argc, const char* argv[]) {
try {
Magick::InitializeMagick(nullptr);
const mappers::VersionParser versionParser;
Log(LogLevel::Info) << versionParser;

commonItems::ConverterVersionParser versionParser;
auto converterVersion = versionParser.importVersion("configurables/version.txt");
logConverterVersion(converterVersion);
if (argc >= 2) {
Log(LogLevel::Info) << "ImperatorToCK3 takes no parameters.";
Log(LogLevel::Info) << "It uses configuration.txt, configured manually or by the frontend.";
}
convertImperatorToCK3(versionParser);

convertImperatorToCK3(converterVersion);
return 0;
}
catch (const std::exception& e) {
Expand Down
2 changes: 0 additions & 2 deletions ImperatorToCK3Tests/ImperatorToCK3Tests.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@
<ClCompile Include="..\ImperatorToCK3\Source\Mappers\TagTitleMapper\TagTitleMapping.cpp" />
<ClCompile Include="..\ImperatorToCK3\Source\Mappers\TraitMapper\TraitMapper.cpp" />
<ClCompile Include="..\ImperatorToCK3\Source\Mappers\TraitMapper\TraitMapping.cpp" />
<ClCompile Include="..\ImperatorToCK3\Source\Mappers\VersionParser\VersionParser.cpp" />
<ClCompile Include="AccessoryGenesTests.cpp" />
<ClCompile Include="CK3WorldTests\Character\CK3CharacterTests.cpp" />
<ClCompile Include="CK3WorldTests\Dynasties\DynastyTests.cpp" />
Expand Down Expand Up @@ -292,7 +291,6 @@
<ClCompile Include="MapperTests\TagTitleMapper\TagTitleMappingTests.cpp" />
<ClCompile Include="MapperTests\TraitMapper\TraitMapperTests.cpp" />
<ClCompile Include="MapperTests\TraitMapper\TraitMappingTests.cpp" />
<ClCompile Include="MapperTests\VersionParser\VersionParserTests.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\ImperatorToCK3\Source\CommonUtilities\DatedHistoryBlock.h" />
Expand Down
9 changes: 0 additions & 9 deletions ImperatorToCK3Tests/ImperatorToCK3Tests.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@
<Filter Include="MapperTests">
<UniqueIdentifier>{8b821bea-0ec6-4690-9411-14c66a11f938}</UniqueIdentifier>
</Filter>
<Filter Include="MapperTests\VersionParser">
<UniqueIdentifier>{fe425519-205f-470d-bd7a-8fc120079608}</UniqueIdentifier>
</Filter>
<Filter Include="Sources">
<UniqueIdentifier>{7b11c93b-e646-48f4-be4f-a324ffc0b220}</UniqueIdentifier>
</Filter>
Expand Down Expand Up @@ -126,12 +123,6 @@
<ClCompile Include="ImperatorWorldTests\Characters\CharacterTests.cpp">
<Filter>ImperatorWorldTests\Characters</Filter>
</ClCompile>
<ClCompile Include="MapperTests\VersionParser\VersionParserTests.cpp">
<Filter>MapperTests\VersionParser</Filter>
</ClCompile>
<ClCompile Include="..\ImperatorToCK3\Source\Mappers\VersionParser\VersionParser.cpp">
<Filter>Sources</Filter>
</ClCompile>
<ClCompile Include="..\ImperatorToCK3\Source\Imperator\Characters\Character.cpp">
<Filter>Sources</Filter>
</ClCompile>
Expand Down
Loading

0 comments on commit 07c092b

Please sign in to comment.