mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] egl: implement preset deletion
This commit is contained in:
parent
dc27638025
commit
1717555187
@ -289,6 +289,24 @@ static void createPreset(struct EGL_PostProcess * this)
|
||||
this->activePreset = stringlist_push(this->presets, strdup(this->presetEdit));
|
||||
}
|
||||
|
||||
static void deletePreset(struct EGL_PostProcess * this)
|
||||
{
|
||||
char * path;
|
||||
alloc_sprintf(&path, "%s/%s", this->presetDir,
|
||||
stringlist_at(this->presets, this->activePreset));
|
||||
if (!path)
|
||||
{
|
||||
DEBUG_ERROR("Failed to allocate memory");
|
||||
return;
|
||||
}
|
||||
|
||||
unlink(path);
|
||||
free(path);
|
||||
stringlist_remove(this->presets, this->activePreset);
|
||||
if (this->activePreset >= stringlist_count(this->presets))
|
||||
this->activePreset = stringlist_count(this->presets) - 1;
|
||||
}
|
||||
|
||||
static bool presetsUI(struct EGL_PostProcess * this)
|
||||
{
|
||||
if (!this->presets)
|
||||
@ -336,6 +354,11 @@ static bool presetsUI(struct EGL_PostProcess * this)
|
||||
igOpenPopup("Create preset", ImGuiPopupFlags_None);
|
||||
}
|
||||
|
||||
igSameLine(0.0f, -1.0f);
|
||||
|
||||
if (igButton("Delete preset", (ImVec2) { 0.0f, 0.0f }) && this->activePreset >= 0)
|
||||
deletePreset(this);
|
||||
|
||||
if (igBeginPopupModal("Create preset", NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
||||
{
|
||||
igText("Enter a name for the new preset:");
|
||||
|
Loading…
Reference in New Issue
Block a user