Fix small CC editor bugs

This commit is contained in:
Llennpie 2024-01-06 20:51:03 -05:00
parent aef6fbe6e7
commit 5cc45a7c9b
2 changed files with 11 additions and 6 deletions

View file

@ -270,12 +270,11 @@ void OpenModelCCSelector(Model model, std::vector<std::string> list, std::string
// Right-Click Menu
if (ImGui::BeginPopupContextItem()) {
if (label_name_lower != "default" || label_name_lower != "../default") {
ImGui::Text("%s.gs", label_name.c_str());
imgui_bundled_tooltip((model.FolderPath + "/colorcodes/" + label_name + ".gs").c_str());
ImGui::Separator();
ImGui::Text("%s.gs", label_name.c_str());
imgui_bundled_tooltip((model.FolderPath + "/colorcodes/" + label_name + ".gs").c_str());
// Delete GS File
// Delete GS File
if (label_name_lower != "default" && label_name_lower != "../default") {
if (ImGui::Button(ICON_FK_TRASH " Delete File"))
ImGui::OpenPopup("###delete_m_gs_file");
if (ImGui::BeginPopup("###delete_m_gs_file")) {
@ -293,7 +292,8 @@ void OpenModelCCSelector(Model model, std::vector<std::string> list, std::string
ImGui::EndPopup();
}
}
ImGui::Separator();
ImGui::TextDisabled("%i color code(s)", list.size());
if (ImGui::Button(ICON_FK_UNDO " Refresh")) {
RefreshColorCodeList();

View file

@ -254,6 +254,11 @@ void SaveGSFile(ColorCode colorCode, std::string filePath) {
}
void DeleteGSFile(std::string filePath) {
// Disallow paths that reach out of bounds
if (filePath.find("/colorcodes/") == std::string::npos ||
filePath.find("../") != std::string::npos)
return;
if (fs::exists(filePath))
fs::remove(filePath);
}