Skip to content

Commit

Permalink
Merge branch 'collapsable-separators' into mod-separators
Browse files Browse the repository at this point in the history
  • Loading branch information
SnazzyPanda committed Dec 13, 2023
2 parents a29129e + d5af7d5 commit 92e3eba
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions Lamp/Control/lampControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace Lamp::Core{
std::list<std::pair<std::string,bool *>> ExtraOptions;
std::string temp{"0"};

bool collapsUntilNextSeparator = false;

/**
* @brief Calculates the Levenshtein distance between two strings.
Expand Down Expand Up @@ -205,22 +206,40 @@ namespace Lamp::Core{

int i = 0;
for (auto it = ModList.begin(); it != ModList.end(); ++it) {
if(this->collapsUntilNextSeparator){
if((*it)->modType == Lamp::Games::getInstance().currentGame->SeparatorModType()){
this->collapsUntilNextSeparator = false;
} else{
i++; // this probable messes stuff up
continue;
}
}

ImGui::TableNextColumn();
if(lampConfig::getInstance().listHighlight == i) {
ImGui::TableSetBgColor(ImGuiTableBgTarget_CellBg, lampControl::getInstance().Colour_SearchHighlight);
}


std::string enabledButtonText = "Enabled##" + std::to_string(i);
std::string disabledButtonText = "Disabled##" + std::to_string(i);
if((*it)->modType == Lamp::Games::getInstance().currentGame->SeparatorModType()){
enabledButtonText = "Expand##" + std::to_string(i);
disabledButtonText = "Collapse##" + std::to_string(i);
}
if((*it)->enabled) {
if((*it)->modType == Lamp::Games::getInstance().currentGame->SeparatorModType()){
this->collapsUntilNextSeparator = true;
}

ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4)lampControl::getInstance().Colour_ButtonAlt);
if (ImGui::Button(("Enabled##" + std::to_string(i)).c_str())) {
if (ImGui::Button(enabledButtonText.c_str())) {
(*it)->enabled = false;
Core::FS::lampIO::saveModList(Lamp::Games::getInstance().currentGame->Ident().ShortHand, ModList, Games::getInstance().currentProfile);
}
ImGui::PopStyleColor(1);
}else{
if (ImGui::Button(("Disabled##" + std::to_string(i)).c_str())) {
if (ImGui::Button(disabledButtonText.c_str())) {
(*it)->enabled = true;
Core::FS::lampIO::saveModList(Lamp::Games::getInstance().currentGame->Ident().ShortHand, ModList, Games::getInstance().currentProfile);
}
Expand Down

0 comments on commit 92e3eba

Please sign in to comment.