diff --git a/SporeModManager/Makefile b/SporeModManager/Makefile index 7dcc184..2f68970 100644 --- a/SporeModManager/Makefile +++ b/SporeModManager/Makefile @@ -53,8 +53,14 @@ ifneq ($(MINGW), 0) endif HEADER_FILES := \ - $(SOURCE_DIR)/SporeModManager.hpp \ - $(SOURCE_DIR)/SporeModManagerHelpers.hpp \ + $(SOURCE_DIR)/SporeModManager.hpp \ + $(SOURCE_DIR)/SporeModManagerHelpers/FileVersion.hpp \ + $(SOURCE_DIR)/SporeModManagerHelpers/SporeModXml.hpp \ + $(SOURCE_DIR)/SporeModManagerHelpers/SporeMod.hpp \ + $(SOURCE_DIR)/SporeModManagerHelpers/String.hpp \ + $(SOURCE_DIR)/SporeModManagerHelpers/Path.hpp \ + $(SOURCE_DIR)/SporeModManagerHelpers/Zip.hpp \ + $(SOURCE_DIR)/SporeModManagerHelpers/UI.hpp \ $(SOURCE_DIR)/../version.h diff --git a/SporeModManager/SporeModManager.cpp b/SporeModManager/SporeModManager.cpp index e711e5c..3b4ea67 100644 --- a/SporeModManager/SporeModManager.cpp +++ b/SporeModManager/SporeModManager.cpp @@ -10,8 +10,12 @@ #include #include +#include "SporeModManagerHelpers/SporeMod.hpp" +#include "SporeModManagerHelpers/String.hpp" +#include "SporeModManagerHelpers/Path.hpp" +#include "SporeModManagerHelpers/Zip.hpp" +#include "SporeModManagerHelpers/UI.hpp" #include "SporeModManager.hpp" -#include "SporeModManagerHelpers.hpp" using namespace SporeModManagerHelpers; diff --git a/SporeModManager/SporeModManager.vcxproj b/SporeModManager/SporeModManager.vcxproj index 4b9903b..37ecb80 100644 --- a/SporeModManager/SporeModManager.vcxproj +++ b/SporeModManager/SporeModManager.vcxproj @@ -136,7 +136,13 @@ - + + + + + + + diff --git a/SporeModManager/SporeModManager.vcxproj.filters b/SporeModManager/SporeModManager.vcxproj.filters index bbbb393..0e21dd2 100644 --- a/SporeModManager/SporeModManager.vcxproj.filters +++ b/SporeModManager/SporeModManager.vcxproj.filters @@ -28,6 +28,9 @@ {a6d9c111-91ba-4900-acf6-60049f263cea} + + {9e43d5cf-31db-4c9d-946e-0dba04fb85fe} + @@ -92,9 +95,6 @@ Header Files - - Header Files - Header Files @@ -104,6 +104,27 @@ Header Files + + Header Files\SporeModManagerHelpers + + + Header Files\SporeModManagerHelpers + + + Header Files\SporeModManagerHelpers + + + Header Files\SporeModManagerHelpers + + + Header Files\SporeModManagerHelpers + + + Header Files\SporeModManagerHelpers + + + Header Files\SporeModManagerHelpers + diff --git a/SporeModManager/SporeModManagerHelpers.hpp b/SporeModManager/SporeModManagerHelpers.hpp deleted file mode 100644 index 7e4e1cf..0000000 --- a/SporeModManager/SporeModManagerHelpers.hpp +++ /dev/null @@ -1,361 +0,0 @@ -/* - * SporeModLoader - https://github.com/Rosalie241/SporeModLoader - * Copyright (C) 2022 Rosalie Wanders - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 3. - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#ifndef SPOREMODMANAGERHELPERS_HPP -#define SPOREMODMANAGERHELPERS_HPP - -#include -#include -#include - -namespace SporeModManagerHelpers -{ - namespace FileVersion - { - struct FileVersionInfo - { - int Major = 0; - int Minor = 0; - int Build = 0; - int Revision = 0; - - bool operator>(const FileVersionInfo& other) const - { - return (Major > other.Major) || - (Major == other.Major && Minor > other.Minor) || - (Major == other.Major && Minor == other.Minor && - Build > other.Build) || - (Major == other.Major && Minor == other.Minor && - Build == other.Build && Revision > other.Revision); - } - - bool operator==(const FileVersionInfo& other) const - { - return Major == other.Major && - Minor == other.Minor && - Build == other.Build && - Revision == other.Revision; - } - - std::string to_string(void) const - { - std::string string; - string = std::to_string(Major) + "."; - string += std::to_string(Minor) + "."; - string += std::to_string(Build) + "."; - string += std::to_string(Revision); - return string; - } - }; - - /// - /// Retrieves file version info for the core lib - /// - bool GetCoreLibFileVersionInfo(FileVersionInfo& fileVersionInfo); - - /// - /// Returns whether the core lib matches the version required by the mod - /// - bool CheckIfCoreLibMatchesVersion(FileVersionInfo& modFileVersionInfo, std::string modName); - - /// - /// Parses FileVersionInfo from string - /// - bool ParseString(std::string string, FileVersionInfo& fileVersionInfo); - - /// - /// Parses FileVersionInfo from a file - /// - bool ParseFile(std::filesystem::path path, FileVersionInfo& fileVersionInfo); - } - - namespace SporeMod - { - enum class InstallLocation - { - ModLibs = 0, - GalacticAdventuresData = 1, - CoreSporeData = 2 - }; - - namespace Xml - { - struct SporeModFile - { - SporeMod::InstallLocation InstallLocation; - std::filesystem::path FileName; - std::filesystem::path FullPath; - - bool operator==(const SporeModFile& other) const - { - return InstallLocation == other.InstallLocation && - FileName == other.FileName && - FullPath == other.FullPath; - } - }; - - struct SporeModInfoComponent - { - std::string Name; - std::string UniqueName; - std::string Description; - bool DefaultChecked; - std::vector Files; - }; - - struct SporeModInfoComponentGroup - { - std::string Name; - std::string UniqueName; - std::vector Components; - }; - - struct SporeModInfoPrerequisite - { - std::vector Files; - }; - - struct SporeModInfoCompatFile - { - std::vector RequiredFiles; - std::vector Files; - }; - - struct SporeModInfo - { - std::string Name; - std::string UniqueName; - std::string Description; - - bool HasModInfoXml = false; - bool IsExperimental = false; - bool RequiresGalaxyReset = false; - bool CausesSaveDataDependency = false; - bool HasCustomInstaller = false; - bool CompatOnly = false; - - FileVersion::FileVersionInfo InstallerVersion; - FileVersion::FileVersionInfo MinimumModAPILibVersion; - - std::vector ComponentGroups; - std::vector Components; - std::vector Prerequisites; - std::vector CompatFiles; - }; - - struct InstalledSporeMod - { - std::string Name; - std::string UniqueName; - std::string Description; - - std::vector InstalledFiles; - - bool operator==(const InstalledSporeMod& other) const - { - return Name == other.Name && - UniqueName == other.UniqueName && - Description == other.Description && - InstalledFiles == other.InstalledFiles; - } - }; - - /// - /// Parses SporeMod.xml buffer into a SporeModInfo - /// - bool ParseSporeModInfo(const std::vector& buffer, SporeModInfo& sporeModInfo); - - /// - /// Retrieves directories - /// > - bool GetDirectories(std::filesystem::path& coreLibsPath, std::filesystem::path& modLibsPath, std::filesystem::path& galacticAdventuresDataPath, std::filesystem::path& coreSporeDataPath); - - /// - /// Saves directories - /// - bool SaveDirectories(std::filesystem::path coreLibsPath, std::filesystem::path modLibsPath, std::filesystem::path galacticAdventuresDataPath, std::filesystem::path coreSporeDataPath); - - /// - /// Retrieves installed mod list - /// - bool GetInstalledModList(std::vector& installedSporeModList); - - /// - /// Saves installed mod list - /// - bool SaveInstalledModList(const std::vector& installedSporeModList); - } - - /// - /// Tries to find installed mod with uniqueName - /// - bool FindInstalledMod(std::string uniqueName, int& installedSporeModId, const std::vector& installedSporeMods); - - /// - /// Configures sporemod file - /// - bool ConfigureSporeMod(void* zipFile, const Xml::SporeModInfo& sporeModInfo, Xml::InstalledSporeMod& installedSporeMod, const std::vector& installedSporeMods); - - /// - /// Configures package file - /// - bool ConfigurePackage(const std::filesystem::path& path, Xml::InstalledSporeMod& installedSporeMod, const std::vector& installedSporeMods); - - /// - /// Installs sporemod file - /// - bool InstallSporeMod(void* zipFile, const Xml::InstalledSporeMod& installedSporeMod); - - /// - /// Installs package file - /// - bool InstallPackage(const std::filesystem::path& path, const Xml::InstalledSporeMod& installedSporeMod); - } - - namespace Path - { - /// - /// Sets directories for current session - /// > - void SetDirectories(std::filesystem::path coreLibsPath, std::filesystem::path modLibsPath, std::filesystem::path galacticAdventuresDataPath, std::filesystem::path coreSporeDataPath); - - /// - /// Returns wether all required paths exist - /// - bool CheckIfPathsExist(void); - - /// - /// Returns the combined path of paths - /// - std::filesystem::path Combine(std::vector paths); - - /// - /// Returns the absolute path of path - /// - std::filesystem::path GetAbsolutePath(std::filesystem::path path); - - /// - /// Retrieves full installation path - /// - std::filesystem::path GetFullInstallPath(SporeMod::InstallLocation installLocation, std::filesystem::path path); - - /// - /// Returns full path from the executable (without the executable filename) - /// - std::filesystem::path GetCurrentExecutablePath(void); - - /// - /// Returns full path to the config file - /// - std::filesystem::path GetConfigFilePath(void); - - /// - /// Returns the CoreLibs path - /// - std::filesystem::path GetCoreLibsPath(void); - } - - namespace UI - { - /// - /// Sets verbose mode - /// - void SetVerboseMode(bool value); - - /// - /// Gets verbose mode - /// - bool GetVerboseMode(void); - - /// - /// Sets no input mode - /// - void SetNoInputMode(bool value); - - /// - /// Asks user for an integer - /// - void AskUserInput(std::string text, int& number, std::optional defaultNumber, int min, int max); - - /// - /// Asks user for an integers - /// - void AskUserInput(std::string text, char delimiter, std::vector& numbers, std::vector defaultNumbers, int min, int max); - - /// - /// Asks user for a boolean - /// - void AskUserInput(std::string text, bool& boolValue, bool defaultValue); - } - - namespace Zip - { - typedef void* ZipFile; - - /// - /// Opens the given zip file - /// - bool OpenFile(ZipFile& zipFile, std::filesystem::path path); - - /// - /// Closes the given zip - /// - bool CloseFile(ZipFile zipFile); - - /// - /// Retrieves file list of the given zip - /// - bool GetFileList(ZipFile zipFile, std::vector& fileList); - - /// - /// Locates file in given zip - /// - bool LocateFile(ZipFile zipFile, std::filesystem::path file); - - /// - /// Extracts file to outputFile - /// - bool ExtractFile(ZipFile zipFile, std::filesystem::path file, std::filesystem::path outputFile); - - /// - /// Extracts file to buffer - /// - bool ExtractFile(ZipFile zipFile, std::filesystem::path file, std::vector& buffer); - } - - namespace String - { - /// - /// Splits the given string by the delimiter - /// - std::vector Split(std::string string, char delimiter); - - /// - /// Splits the given string by the delimiter - /// - std::vector Split(std::wstring string, wchar_t delimiter); - - /// - /// Joins numbers to string with delimiter - /// - std::string Join(std::vector numbers, char delimiter); - - /// - /// Replaces findString with replacementString in string - /// - std::string Replace(std::string string, std::string findString, std::string replacementString); - - /// - /// Returns the lowercase version of the given string - /// - std::string Lowercase(std::string string); - } -} - -#endif // SPOREMODMANAGERHELPERS_HPP diff --git a/SporeModManager/SporeModManagerHelpers/FileVersion.cpp b/SporeModManager/SporeModManagerHelpers/FileVersion.cpp index 1c8f283..7250af9 100644 --- a/SporeModManager/SporeModManagerHelpers/FileVersion.cpp +++ b/SporeModManager/SporeModManagerHelpers/FileVersion.cpp @@ -7,7 +7,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "SporeModManagerHelpers.hpp" +#include "FileVersion.hpp" +#include "String.hpp" +#include "Path.hpp" #include #include diff --git a/SporeModManager/SporeModManagerHelpers/FileVersion.hpp b/SporeModManager/SporeModManagerHelpers/FileVersion.hpp new file mode 100644 index 0000000..1832fbb --- /dev/null +++ b/SporeModManager/SporeModManagerHelpers/FileVersion.hpp @@ -0,0 +1,78 @@ +/* + * SporeModLoader - https://github.com/Rosalie241/SporeModLoader + * Copyright (C) 2022 Rosalie Wanders + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef SPOREMODMANAGERHELPERS_FILEVERSION_HPP +#define SPOREMODMANAGERHELPERS_FILEVERSION_HPP + +#include +#include + +namespace SporeModManagerHelpers +{ + namespace FileVersion + { + struct FileVersionInfo + { + int Major = 0; + int Minor = 0; + int Build = 0; + int Revision = 0; + + bool operator>(const FileVersionInfo& other) const + { + return (Major > other.Major) || + (Major == other.Major && Minor > other.Minor) || + (Major == other.Major && Minor == other.Minor && + Build > other.Build) || + (Major == other.Major && Minor == other.Minor && + Build == other.Build && Revision > other.Revision); + } + + bool operator==(const FileVersionInfo& other) const + { + return Major == other.Major && + Minor == other.Minor && + Build == other.Build && + Revision == other.Revision; + } + + std::string to_string(void) const + { + std::string string; + string = std::to_string(Major) + "."; + string += std::to_string(Minor) + "."; + string += std::to_string(Build) + "."; + string += std::to_string(Revision); + return string; + } + }; + + /// + /// Retrieves file version info for the core lib + /// + bool GetCoreLibFileVersionInfo(FileVersionInfo& fileVersionInfo); + + /// + /// Returns whether the core lib matches the version required by the mod + /// + bool CheckIfCoreLibMatchesVersion(FileVersionInfo& modFileVersionInfo, std::string modName); + + /// + /// Parses FileVersionInfo from string + /// + bool ParseString(std::string string, FileVersionInfo& fileVersionInfo); + + /// + /// Parses FileVersionInfo from a file + /// + bool ParseFile(std::filesystem::path path, FileVersionInfo& fileVersionInfo); + } +} + +#endif // SPOREMODMANAGERHELPERS_FILEVERSION_HPP \ No newline at end of file diff --git a/SporeModManager/SporeModManagerHelpers/Path.cpp b/SporeModManager/SporeModManagerHelpers/Path.cpp index 8094826..c1ead95 100644 --- a/SporeModManager/SporeModManagerHelpers/Path.cpp +++ b/SporeModManager/SporeModManagerHelpers/Path.cpp @@ -7,7 +7,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "SporeModManagerHelpers.hpp" +#include "Path.hpp" #include #include diff --git a/SporeModManager/SporeModManagerHelpers/Path.hpp b/SporeModManager/SporeModManagerHelpers/Path.hpp new file mode 100644 index 0000000..9dc144f --- /dev/null +++ b/SporeModManager/SporeModManagerHelpers/Path.hpp @@ -0,0 +1,63 @@ +/* + * SporeModLoader - https://github.com/Rosalie241/SporeModLoader + * Copyright (C) 2022 Rosalie Wanders + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef SPOREMODMANAGERHELPERS_PATH_HPP +#define SPOREMODMANAGERHELPERS_PATH_HPP + +#include + +#include "SporeMod.hpp" + +namespace SporeModManagerHelpers +{ + namespace Path + { + /// + /// Sets directories for current session + /// > + void SetDirectories(std::filesystem::path coreLibsPath, std::filesystem::path modLibsPath, std::filesystem::path galacticAdventuresDataPath, std::filesystem::path coreSporeDataPath); + + /// + /// Returns wether all required paths exist + /// + bool CheckIfPathsExist(void); + + /// + /// Returns the combined path of paths + /// + std::filesystem::path Combine(std::vector paths); + + /// + /// Returns the absolute path of path + /// + std::filesystem::path GetAbsolutePath(std::filesystem::path path); + + /// + /// Retrieves full installation path + /// + std::filesystem::path GetFullInstallPath(SporeMod::InstallLocation installLocation, std::filesystem::path path); + + /// + /// Returns full path from the executable (without the executable filename) + /// + std::filesystem::path GetCurrentExecutablePath(void); + + /// + /// Returns full path to the config file + /// + std::filesystem::path GetConfigFilePath(void); + + /// + /// Returns the CoreLibs path + /// + std::filesystem::path GetCoreLibsPath(void); + } +} + +#endif // SPOREMODMANAGERHELPERS_PATH_HPP \ No newline at end of file diff --git a/SporeModManager/SporeModManagerHelpers/SporeMod.cpp b/SporeModManager/SporeModManagerHelpers/SporeMod.cpp index 80df7f4..77fe85e 100644 --- a/SporeModManager/SporeModManagerHelpers/SporeMod.cpp +++ b/SporeModManager/SporeModManagerHelpers/SporeMod.cpp @@ -7,7 +7,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "SporeModManagerHelpers.hpp" +#include "SporeMod.hpp" +#include "String.hpp" +#include "Path.hpp" +#include "UI.hpp" #include #include @@ -63,7 +66,7 @@ bool SporeMod::FindInstalledMod(std::string uniqueName, int& installedSporeModId return false; } -bool SporeMod::ConfigureSporeMod(void* zipFile, const Xml::SporeModInfo& sporeModInfo, Xml::InstalledSporeMod& installedSporeMod, const std::vector &installedSporeMods) +bool SporeMod::ConfigureSporeMod(Zip::ZipFile zipFile, const Xml::SporeModInfo& sporeModInfo, Xml::InstalledSporeMod& installedSporeMod, const std::vector &installedSporeMods) { Xml::SporeModInfoComponent component; size_t componentsSize; @@ -296,7 +299,7 @@ bool SporeMod::ConfigurePackage(const std::filesystem::path& path, Xml::Installe return true; } -bool SporeMod::InstallSporeMod(void* zipFile, const Xml::InstalledSporeMod& installedSporeMod) +bool SporeMod::InstallSporeMod(Zip::ZipFile zipFile, const Xml::InstalledSporeMod& installedSporeMod) { std::cout << "-> Installing " << installedSporeMod.Name << std::endl; diff --git a/SporeModManager/SporeModManagerHelpers/SporeMod.hpp b/SporeModManager/SporeModManagerHelpers/SporeMod.hpp new file mode 100644 index 0000000..69743b4 --- /dev/null +++ b/SporeModManager/SporeModManagerHelpers/SporeMod.hpp @@ -0,0 +1,51 @@ +/* + * SporeModLoader - https://github.com/Rosalie241/SporeModLoader + * Copyright (C) 2022 Rosalie Wanders + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef SPOREMODMANAGERHELPERS_SPOREMOD_HPP +#define SPOREMODMANAGERHELPERS_SPOREMOD_HPP + +#include +#include +#include + +#include "SporeModXml.hpp" +#include "Zip.hpp" + +namespace SporeModManagerHelpers +{ + namespace SporeMod + { + /// + /// Tries to find installed mod with uniqueName + /// + bool FindInstalledMod(std::string uniqueName, int& installedSporeModId, const std::vector& installedSporeMods); + + /// + /// Configures sporemod file + /// + bool ConfigureSporeMod(Zip::ZipFile zipFile, const Xml::SporeModInfo& sporeModInfo, Xml::InstalledSporeMod& installedSporeMod, const std::vector& installedSporeMods); + + /// + /// Configures package file + /// + bool ConfigurePackage(const std::filesystem::path& path, Xml::InstalledSporeMod& installedSporeMod, const std::vector& installedSporeMods); + + /// + /// Installs sporemod file + /// + bool InstallSporeMod(Zip::ZipFile zipFile, const Xml::InstalledSporeMod& installedSporeMod); + + /// + /// Installs package file + /// + bool InstallPackage(const std::filesystem::path& path, const Xml::InstalledSporeMod& installedSporeMod); + } +} + +#endif // SPOREMODMANAGERHELPERS_SPOREMOD_HPP diff --git a/SporeModManager/SporeModManagerHelpers/SporeModXml.cpp b/SporeModManager/SporeModManagerHelpers/SporeModXml.cpp index 70d1d20..58085f0 100644 --- a/SporeModManager/SporeModManagerHelpers/SporeModXml.cpp +++ b/SporeModManager/SporeModManagerHelpers/SporeModXml.cpp @@ -7,7 +7,9 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "SporeModManagerHelpers.hpp" +#include "SporeModXml.hpp" +#include "String.hpp" +#include "Path.hpp" #include #include diff --git a/SporeModManager/SporeModManagerHelpers/SporeModXml.hpp b/SporeModManager/SporeModManagerHelpers/SporeModXml.hpp new file mode 100644 index 0000000..f57697f --- /dev/null +++ b/SporeModManager/SporeModManagerHelpers/SporeModXml.hpp @@ -0,0 +1,139 @@ +/* + * SporeModLoader - https://github.com/Rosalie241/SporeModLoader + * Copyright (C) 2022 Rosalie Wanders + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef SPOREMODMANAGERHELPERS_SPOREMODXML_HPP +#define SPOREMODMANAGERHELPERS_SPOREMODXML_HPP + +#include +#include + +#include "FileVersion.hpp" + +namespace SporeModManagerHelpers +{ + namespace SporeMod + { + enum class InstallLocation + { + ModLibs = 0, + GalacticAdventuresData = 1, + CoreSporeData = 2 + }; + + namespace Xml + { + struct SporeModFile + { + SporeMod::InstallLocation InstallLocation; + std::filesystem::path FileName; + std::filesystem::path FullPath; + + bool operator==(const SporeModFile& other) const + { + return InstallLocation == other.InstallLocation && + FileName == other.FileName && + FullPath == other.FullPath; + } + }; + + struct SporeModInfoComponent + { + std::string Name; + std::string UniqueName; + std::string Description; + bool DefaultChecked; + std::vector Files; + }; + + struct SporeModInfoComponentGroup + { + std::string Name; + std::string UniqueName; + std::vector Components; + }; + + struct SporeModInfoPrerequisite + { + std::vector Files; + }; + + struct SporeModInfoCompatFile + { + std::vector RequiredFiles; + std::vector Files; + }; + + struct SporeModInfo + { + std::string Name; + std::string UniqueName; + std::string Description; + + bool HasModInfoXml = false; + bool IsExperimental = false; + bool RequiresGalaxyReset = false; + bool CausesSaveDataDependency = false; + bool HasCustomInstaller = false; + bool CompatOnly = false; + + FileVersion::FileVersionInfo InstallerVersion; + FileVersion::FileVersionInfo MinimumModAPILibVersion; + + std::vector ComponentGroups; + std::vector Components; + std::vector Prerequisites; + std::vector CompatFiles; + }; + + struct InstalledSporeMod + { + std::string Name; + std::string UniqueName; + std::string Description; + + std::vector InstalledFiles; + + bool operator==(const InstalledSporeMod& other) const + { + return Name == other.Name && + UniqueName == other.UniqueName && + Description == other.Description && + InstalledFiles == other.InstalledFiles; + } + }; + + /// + /// Parses SporeMod.xml buffer into a SporeModInfo + /// + bool ParseSporeModInfo(const std::vector& buffer, SporeModInfo& sporeModInfo); + + /// + /// Retrieves directories + /// > + bool GetDirectories(std::filesystem::path& coreLibsPath, std::filesystem::path& modLibsPath, std::filesystem::path& galacticAdventuresDataPath, std::filesystem::path& coreSporeDataPath); + + /// + /// Saves directories + /// + bool SaveDirectories(std::filesystem::path coreLibsPath, std::filesystem::path modLibsPath, std::filesystem::path galacticAdventuresDataPath, std::filesystem::path coreSporeDataPath); + + /// + /// Retrieves installed mod list + /// + bool GetInstalledModList(std::vector& installedSporeModList); + + /// + /// Saves installed mod list + /// + bool SaveInstalledModList(const std::vector& installedSporeModList); + } + } +} + +#endif // SPOREMODMANAGERHELPERS_SPOREMODXML_HPP \ No newline at end of file diff --git a/SporeModManager/SporeModManagerHelpers/String.cpp b/SporeModManager/SporeModManagerHelpers/String.cpp index 011d54b..61a8bc3 100644 --- a/SporeModManager/SporeModManagerHelpers/String.cpp +++ b/SporeModManager/SporeModManagerHelpers/String.cpp @@ -7,7 +7,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "SporeModManagerHelpers.hpp" +#include "String.hpp" #include #include diff --git a/SporeModManager/SporeModManagerHelpers/String.hpp b/SporeModManager/SporeModManagerHelpers/String.hpp new file mode 100644 index 0000000..8bcabfd --- /dev/null +++ b/SporeModManager/SporeModManagerHelpers/String.hpp @@ -0,0 +1,47 @@ +/* + * SporeModLoader - https://github.com/Rosalie241/SporeModLoader + * Copyright (C) 2022 Rosalie Wanders + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef SPOREMODMANAGERHELPERS_STRING_HPP +#define SPOREMODMANAGERHELPERS_STRING_HPP + +#include +#include + +namespace SporeModManagerHelpers +{ + namespace String + { + /// + /// Splits the given string by the delimiter + /// + std::vector Split(std::string string, char delimiter); + + /// + /// Splits the given string by the delimiter + /// + std::vector Split(std::wstring string, wchar_t delimiter); + + /// + /// Joins numbers to string with delimiter + /// + std::string Join(std::vector numbers, char delimiter); + + /// + /// Replaces findString with replacementString in string + /// + std::string Replace(std::string string, std::string findString, std::string replacementString); + + /// + /// Returns the lowercase version of the given string + /// + std::string Lowercase(std::string string); + } +} + +#endif // SPOREMODMANAGERHELPERS_STRING_HPP \ No newline at end of file diff --git a/SporeModManager/SporeModManagerHelpers/UI.cpp b/SporeModManager/SporeModManagerHelpers/UI.cpp index a298ce0..b7f6caf 100644 --- a/SporeModManager/SporeModManagerHelpers/UI.cpp +++ b/SporeModManager/SporeModManagerHelpers/UI.cpp @@ -7,7 +7,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "SporeModManagerHelpers.hpp" +#include "String.hpp" +#include "UI.hpp" #include #include diff --git a/SporeModManager/SporeModManagerHelpers/UI.hpp b/SporeModManager/SporeModManagerHelpers/UI.hpp new file mode 100644 index 0000000..1e9637a --- /dev/null +++ b/SporeModManager/SporeModManagerHelpers/UI.hpp @@ -0,0 +1,53 @@ +/* + * SporeModLoader - https://github.com/Rosalie241/SporeModLoader + * Copyright (C) 2022 Rosalie Wanders + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef SPOREMODMANAGERHELPERS_UI_HPP +#define SPOREMODMANAGERHELPERS_UI_HPP + +#include +#include +#include + +namespace SporeModManagerHelpers +{ + namespace UI + { + /// + /// Sets verbose mode + /// + void SetVerboseMode(bool value); + + /// + /// Gets verbose mode + /// + bool GetVerboseMode(void); + + /// + /// Sets no input mode + /// + void SetNoInputMode(bool value); + + /// + /// Asks user for an integer + /// + void AskUserInput(std::string text, int& number, std::optional defaultNumber, int min, int max); + + /// + /// Asks user for an integers + /// + void AskUserInput(std::string text, char delimiter, std::vector& numbers, std::vector defaultNumbers, int min, int max); + + /// + /// Asks user for a boolean + /// + void AskUserInput(std::string text, bool& boolValue, bool defaultValue); + } +} + +#endif // SPOREMODMANAGERHELPERS_UI_HPP \ No newline at end of file diff --git a/SporeModManager/SporeModManagerHelpers/Zip.cpp b/SporeModManager/SporeModManagerHelpers/Zip.cpp index 5b580ad..f97a755 100644 --- a/SporeModManager/SporeModManagerHelpers/Zip.cpp +++ b/SporeModManager/SporeModManagerHelpers/Zip.cpp @@ -7,7 +7,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#include "SporeModManagerHelpers.hpp" +#include "Zip.hpp" #include #include diff --git a/SporeModManager/SporeModManagerHelpers/Zip.hpp b/SporeModManager/SporeModManagerHelpers/Zip.hpp new file mode 100644 index 0000000..6f5dd2c --- /dev/null +++ b/SporeModManager/SporeModManagerHelpers/Zip.hpp @@ -0,0 +1,54 @@ +/* + * SporeModLoader - https://github.com/Rosalie241/SporeModLoader + * Copyright (C) 2022 Rosalie Wanders + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 3. + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +#ifndef SPOREMODMANAGERHELPERS_ZIP_HPP +#define SPOREMODMANAGERHELPERS_ZIP_HPP + +#include +#include + +namespace SporeModManagerHelpers +{ + namespace Zip + { + typedef void* ZipFile; + + /// + /// Opens the given zip file + /// + bool OpenFile(ZipFile& zipFile, std::filesystem::path path); + + /// + /// Closes the given zip + /// + bool CloseFile(ZipFile zipFile); + + /// + /// Retrieves file list of the given zip + /// + bool GetFileList(ZipFile zipFile, std::vector& fileList); + + /// + /// Locates file in given zip + /// + bool LocateFile(ZipFile zipFile, std::filesystem::path file); + + /// + /// Extracts file to outputFile + /// + bool ExtractFile(ZipFile zipFile, std::filesystem::path file, std::filesystem::path outputFile); + + /// + /// Extracts file to buffer + /// + bool ExtractFile(ZipFile zipFile, std::filesystem::path file, std::vector& buffer); + } +} + +#endif // SPOREMODMANAGERHELPERS_ZIP_HPP \ No newline at end of file diff --git a/SporeModManager/main.cpp b/SporeModManager/main.cpp index fd0a364..f2e4e11 100644 --- a/SporeModManager/main.cpp +++ b/SporeModManager/main.cpp @@ -7,8 +7,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +#include "SporeModManagerHelpers/String.hpp" +#include "SporeModManagerHelpers/Path.hpp" +#include "SporeModManagerHelpers/UI.hpp" #include "SporeModManager.hpp" -#include "SporeModManagerHelpers.hpp" #include "../version.h"