Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/CHollingworth/Lamp
Browse files Browse the repository at this point in the history
Fixed conflict with CmakeLists
  • Loading branch information
CHollingworth committed Sep 13, 2023
2 parents 1f3a014 + cbed58b commit 8ac9175
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 21 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Lamp
A Mod Manager for games, made for Linux! As an alternative to Vortex and MO2.

[!IMPORTANT]
This tool is in its early days please see the contributing section to help add more to it.
This tool is in its early days please see the contributing section to help add more to it,
For now i am just one person working on this tool updates will be slow.

# Usage

Expand Down Expand Up @@ -35,6 +35,8 @@ This tool is in its early days please see the contributing section to help add m
## Running Requirements
- Vulkan Support
- Zenity
- glfw
- X11

## Build Requirements
- Vulkan
Expand Down
74 changes: 58 additions & 16 deletions game-data/BG3/BG3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,22 +146,22 @@ namespace Lamp {
ImGui::Begin("BG3 Steam Path Setup", NULL,windowFlags); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)

ImGui::Text("BG3 Steam Directory");
if(ImGui::Button((installDirPath+"##installpath").c_str())){
if(ImGui::Button((installDirPath+"##installpath").c_str())) {
nfdchar_t *outPath = NULL;
nfdresult_t result = NFD_PickFolder( NULL, &outPath );
nfdresult_t result = NFD_PickFolder(NULL, &outPath);

if ( result == NFD_OKAY ) {
if (result == NFD_OKAY) {
puts(outPath);
installDirPath = outPath;
Lamp::Core::lampFilesystem::getInstance().saveKeyData(Core::lampConfig::BG3, "installDirPath",installDirPath);
}
else if ( result == NFD_CANCEL ) {

} else if (result == NFD_CANCEL) {
puts("User pressed cancel.");
}
else {
printf("Error: %s\n", NFD_GetError() );
} else {
printf("Error: %s\n", NFD_GetError());
}
}

ImGui::Separator();

ImGui::Text("BG3 AppData Directory");
Expand All @@ -183,9 +183,43 @@ namespace Lamp {
}
ImGui::Separator();

if(checkLock) {
ImGui::Separator();
ImGui::Text("WARNING: Incorrect folder may be selected.");
}


if (ImGui::Button("Close")){

std::stringstream ss(installDirPath);
std::stringstream ssE(appDataPath);
std::string token;
std::string folderNameA;
std::string folderNameB;
while (std::getline(ss, token, '/')) {
// Skip empty tokens (e.g., double slashes)
if (!token.empty()) {
folderNameA = token;
}
}
while (std::getline(ssE, token, '/')) {
// Skip empty tokens (e.g., double slashes)
if (!token.empty()) {
folderNameB = token;
}
}

if(folderNameA == "Baldurs Gate 3" && folderNameB == "Baldur's Gate 3"){
ImGui::End();
checkLock = false;
return true;
}else{
checkLock = true;
}


ImGui::End();
return true;
return false;
}

ImGui::End();
Expand Down Expand Up @@ -336,15 +370,21 @@ namespace Lamp {
if (std::regex_match((*it)->ArchivePath, std::regex("^.*\\.(zip)$"))) {
Lamp::Core::lampFilesystem::getInstance().extractSpecificFileType(
Lamp::Core::lampConfig::BG3, bit7z::BitFormat::Zip, (*it), "/Mods", "pak");
collectJsonData();
if(collectJsonData()){
break;
}
} else if (std::regex_match((*it)->ArchivePath, std::regex("^.*\\.(rar)$"))) {
Lamp::Core::lampFilesystem::getInstance().extractSpecificFileType(
Lamp::Core::lampConfig::BG3, bit7z::BitFormat::Rar, (*it), "/Mods", "pak");
collectJsonData();
if(collectJsonData()){
break;
}
} else if (std::regex_match((*it)->ArchivePath, std::regex("^.*\\.(7z)$"))) {
Lamp::Core::lampFilesystem::getInstance().extractSpecificFileType(
Lamp::Core::lampConfig::BG3, bit7z::BitFormat::SevenZip, (*it), "/Mods", "pak");
collectJsonData();
if(collectJsonData()){
break;
}
} else {
break;
}
Expand All @@ -361,7 +401,7 @@ namespace Lamp {
return true;
}

void Game::BG3::collectJsonData() {
bool Game::BG3::collectJsonData() {
std::string workingDir = Lamp::Core::lampFilesystem::getInstance().getGameSpecificStoragePath(
Lamp::Core::lampConfig::BG3);
for (const auto& entry : std::filesystem::directory_iterator((workingDir + "/ext").c_str())) {
Expand All @@ -372,13 +412,13 @@ namespace Lamp {

if (!jsonFile.is_open()) {
std::cerr << "Failed to open JSON file." << std::endl;
return;
return false;
}


if (!doc.load_file((workingDir + "/PlayerProfiles/Public/modsettings.lsx").c_str())) {
std::cerr << "Failed to load XML file." << std::endl;
return;
return false;
}

nlohmann::json jsonData;
Expand Down Expand Up @@ -462,10 +502,12 @@ namespace Lamp {
if (!doc.save_file((workingDir + "/PlayerProfiles/Public/modsettings.lsx").c_str())) {
std::cerr << "Failed to save XML file." << std::endl;
}

return true;
}
} else {
std::cerr << "JSON data does not contain 'mods' key." << std::endl;
return;
return false;
}

}
Expand Down
4 changes: 3 additions & 1 deletion game-data/BG3/BG3.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

std::list<Lamp::Core::lampMod::Mod *> ModList;

bool checkLock = false;


static BG3& getInstance()
{
Expand All @@ -49,7 +51,7 @@
bool deployment() override;
void postDeploymentTasks() override;

void collectJsonData();
bool collectJsonData();

void listArchives() override;
private:
Expand Down
8 changes: 7 additions & 1 deletion lampFilesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,14 @@ namespace Lamp {
gameNode.append_attribute("name").set_value(game.c_str());
}

pugi::xml_node keyNode = gameNode.child(key.c_str());
if (keyNode) {
// Key node already exists, so remove it
gameNode.remove_child(key.c_str());
}

// Add a new key node with data as its child value
pugi::xml_node keyNode = gameNode.append_child(key.c_str());
keyNode = gameNode.append_child(key.c_str());
keyNode.text().set(data.c_str());

// Save the modified XML back to the file
Expand Down
1 change: 0 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,6 @@ int main(int, char**)
return 1;
}


glfwSetDropCallback(window, Lamp::Core::lampFilesystem::fileDrop);

ImVector<const char*> extensions;
Expand Down

0 comments on commit 8ac9175

Please sign in to comment.