Skip to content

Commit

Permalink
Fix filter issue, added multiple key filtering.
Browse files Browse the repository at this point in the history
Fix filter issue, added multiple key filtering.
  • Loading branch information
Karaulov committed Nov 24, 2022
1 parent a42e4ed commit 2ff3acd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ vs-project/glfw/src/Release/glfw3.lib
vs-project/bspguy.dir/Debug/vc143.idb
vs-project/glfw/src/Debug/glfw3.lib
vs-project/glfw/src/Release/glfw3.lib
vs-project/bspguy.dir/Debug/bsp.obj.enc
vs-project/bspguy.dir/Debug/bsprenderer.obj.enc
vs-project/bspguy.dir/Debug/renderer.obj.enc
vs-project/bspguy.dir/Debug/bspguy.vcxproj.FileListAbsolute.txt
vs-project/bspguy.dir/Release/bspguy.vcxproj.FileListAbsolute.txt
vs-project/glfw/src/glfw.dir/Debug/glfw.vcxproj.FileListAbsolute.txt
vs-project/glfw/src/glfw.dir/Release/glfw.vcxproj.FileListAbsolute.txt
vs-project/Release/log.txt
*.enc
4 changes: 4 additions & 0 deletions imgui/misc/cpp/imgui_stdlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ static int InputTextCallback(ImGuiInputTextCallbackData* data)
str->resize(data->BufTextLen);
data->Buf = (char*)str->c_str();
}
else
{
str->clear();
}
}
else if (user_data->ChainCallback)
{
Expand Down
46 changes: 38 additions & 8 deletions src/editor/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3914,7 +3914,7 @@ void Gui::drawImportMapWidget()
{
Bsp* bspModel = new Bsp(mapPath);
Bsp* map = g_app->getSelectedMap();

int FaceCount = map->faceCount, NodeCount = map->nodeCount, ClipNodeCount = map->clipnodeCount;

std::vector<BSPPLANE> newPlanes;
Expand All @@ -3927,7 +3927,7 @@ void Gui::drawImportMapWidget()
std::vector<BSPNODE> newNodes;
std::vector<BSPCLIPNODE> newClipnodes;

STRUCTREMAP * remap = new STRUCTREMAP();
STRUCTREMAP* remap = new STRUCTREMAP();

bspModel->copy_bsp_model(0, map, *remap, newPlanes, newVerts, newEdges, newSurfedges, newTexinfo, newFaces, newLightmaps, newNodes, newClipnodes);

Expand Down Expand Up @@ -4281,9 +4281,9 @@ void Gui::drawEntityReport()
else
{
ImGui::BeginGroup();
const int MAX_FILTERS = 1;
static std::string keyFilter[MAX_FILTERS];
static std::string valueFilter[MAX_FILTERS];
static int MAX_FILTERS = 1;
static std::vector<std::string> keyFilter = std::vector<std::string>();
static std::vector<std::string> valueFilter = std::vector<std::string>();
static int lastSelect = -1;
static std::string classFilter = "(none)";
static std::string flagsFilter = "(none)";
Expand All @@ -4299,6 +4299,10 @@ void Gui::drawEntityReport()
if (filterNeeded)
{
visibleEnts.clear();
while (keyFilter.size() < MAX_FILTERS)
keyFilter.push_back(std::string());
while (valueFilter.size() < MAX_FILTERS)
valueFilter.push_back(std::string());

for (int i = 1; i < map->ents.size(); i++)
{
Expand Down Expand Up @@ -4366,7 +4370,7 @@ void Gui::drawEntityReport()
}
}
}
else if (valueFilter[k][0] != '\0')
else if(valueFilter[k].size())
{
std::string searchValue = trimSpaces(toLowerCase(valueFilter[k]));
bool foundMatch = false;
Expand Down Expand Up @@ -4578,27 +4582,53 @@ void Gui::drawEntityReport()

ImGui::Dummy(ImVec2(0, 8));
ImGui::Text("Keyvalue Filter");
ImGui::SameLine();

ImGuiStyle& style = ImGui::GetStyle();
float padding = style.WindowPadding.x * 2 + style.FramePadding.x * 2;
float inputWidth = (ImGui::GetWindowWidth() - (padding + style.ScrollbarSize)) * 0.5f;
float inputWidth = (ImGui::GetWindowWidth() - (padding + style.ScrollbarSize)) * 0.4f;
inputWidth -= smallFont->CalcTextSizeA(fontSize, FLT_MAX, FLT_MAX, " = ").x;

while (keyFilter.size() < MAX_FILTERS)
keyFilter.push_back(std::string());
while (valueFilter.size() < MAX_FILTERS)
valueFilter.push_back(std::string());

for (int i = 0; i < MAX_FILTERS; i++)
{
ImGui::SetNextItemWidth(inputWidth);
if (ImGui::InputText(("##Key" + std::to_string(i)).c_str(), &keyFilter[i]))
{
filterNeeded = true;
}

ImGui::SameLine();
ImGui::Text(" = "); ImGui::SameLine();
ImGui::SetNextItemWidth(inputWidth);

if (ImGui::InputText(("##Value" + std::to_string(i)).c_str(), &valueFilter[i]))
{
filterNeeded = true;
}

if (i == 0)
{
ImGui::SameLine();
if (ImGui::Button("Add", ImVec2(100, 0)))
{
MAX_FILTERS++;
break;
}
}
if (i == 1)
{
ImGui::SameLine();
if (ImGui::Button("Del", ImVec2(100, 0)))
{
if (MAX_FILTERS > 1)
MAX_FILTERS--;
break;
}
}
}

if (ImGui::Checkbox("Partial Matching", &partialMatches))
Expand Down

0 comments on commit 2ff3acd

Please sign in to comment.