mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-11-22 05:27:20 +00:00
[client] egl: show preset errors as modal dialogs
This commit is contained in:
parent
311f7241c6
commit
c85cc7d668
@ -57,6 +57,7 @@ struct EGL_PostProcess
|
|||||||
char * presetDir;
|
char * presetDir;
|
||||||
int activePreset;
|
int activePreset;
|
||||||
char presetEdit[128];
|
char presetEdit[128];
|
||||||
|
char * presetError;
|
||||||
};
|
};
|
||||||
|
|
||||||
void egl_postProcessEarlyInit(void)
|
void egl_postProcessEarlyInit(void)
|
||||||
@ -125,7 +126,13 @@ fail:
|
|||||||
stringlist_free(&this->presets);
|
stringlist_free(&this->presets);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void savePreset(struct EGL_PostProcess * this, const char * name)
|
static void presetError(struct EGL_PostProcess * this, char * message)
|
||||||
|
{
|
||||||
|
free(this->presetError);
|
||||||
|
this->presetError = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool savePreset(struct EGL_PostProcess * this, const char * name)
|
||||||
{
|
{
|
||||||
EGL_Filter * filter;
|
EGL_Filter * filter;
|
||||||
vector_forEach(filter, &this->filters)
|
vector_forEach(filter, &this->filters)
|
||||||
@ -136,21 +143,28 @@ static void savePreset(struct EGL_PostProcess * this, const char * name)
|
|||||||
if (!path)
|
if (!path)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to allocate memory");
|
DEBUG_ERROR("Failed to allocate memory");
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
FILE * file = fopen(path, "w");
|
FILE * file = fopen(path, "w");
|
||||||
if (!file)
|
if (!file)
|
||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to open preset \"%s\" for writing: %s", name, strerror(errno));
|
const char * strError = strerror(errno);
|
||||||
|
DEBUG_ERROR("Failed to open preset \"%s\" for writing: %s", name, strError);
|
||||||
free(path);
|
free(path);
|
||||||
return;
|
|
||||||
|
char * error;
|
||||||
|
alloc_sprintf(&error, "Failed to save preset: %s\nError: %s", name, strError);
|
||||||
|
if (error)
|
||||||
|
presetError(this, error);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
DEBUG_INFO("Saving preset: %s", name);
|
DEBUG_INFO("Saving preset: %s", name);
|
||||||
option_dump(file, "eglFilter");
|
option_dump(file, "eglFilter");
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadPreset(struct EGL_PostProcess * this, const char * name)
|
static void loadPreset(struct EGL_PostProcess * this, const char * name)
|
||||||
@ -167,6 +181,11 @@ static void loadPreset(struct EGL_PostProcess * this, const char * name)
|
|||||||
{
|
{
|
||||||
DEBUG_ERROR("Failed to load preset: %s", name);
|
DEBUG_ERROR("Failed to load preset: %s", name);
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
|
char * error;
|
||||||
|
alloc_sprintf(&error, "Failed to load preset: %s", name);
|
||||||
|
if (error)
|
||||||
|
presetError(this, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
@ -180,9 +199,9 @@ static void loadPreset(struct EGL_PostProcess * this, const char * name)
|
|||||||
static void createPreset(struct EGL_PostProcess * this)
|
static void createPreset(struct EGL_PostProcess * this)
|
||||||
{
|
{
|
||||||
DEBUG_INFO("Create preset: %s", this->presetEdit);
|
DEBUG_INFO("Create preset: %s", this->presetEdit);
|
||||||
char * name = strdup(this->presetEdit);
|
if (!savePreset(this, this->presetEdit))
|
||||||
this->activePreset = stringlist_push(this->presets, name);
|
return;
|
||||||
savePreset(this, name);
|
this->activePreset = stringlist_push(this->presets, strdup(this->presetEdit));
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool presetsUI(struct EGL_PostProcess * this)
|
static bool presetsUI(struct EGL_PostProcess * this)
|
||||||
@ -259,6 +278,26 @@ static bool presetsUI(struct EGL_PostProcess * this)
|
|||||||
igEndPopup();
|
igEndPopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->presetError)
|
||||||
|
igOpenPopup("Preset error", ImGuiPopupFlags_None);
|
||||||
|
|
||||||
|
if (igBeginPopupModal("Preset error", NULL, ImGuiWindowFlags_AlwaysAutoResize))
|
||||||
|
{
|
||||||
|
igText("%s", this->presetError);
|
||||||
|
|
||||||
|
if (!igIsAnyItemActive())
|
||||||
|
igSetKeyboardFocusHere(0);
|
||||||
|
|
||||||
|
if (igButton("OK", (ImVec2) { 0.0f, 0.0f }))
|
||||||
|
{
|
||||||
|
free(this->presetError);
|
||||||
|
this->presetError = NULL;
|
||||||
|
igCloseCurrentPopup();
|
||||||
|
}
|
||||||
|
|
||||||
|
igEndPopup();
|
||||||
|
}
|
||||||
|
|
||||||
return redraw;
|
return redraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -399,6 +438,7 @@ void egl_postProcessFree(EGL_PostProcess ** pp)
|
|||||||
stringlist_free(&this->presets);
|
stringlist_free(&this->presets);
|
||||||
|
|
||||||
egl_modelFree(&this->model);
|
egl_modelFree(&this->model);
|
||||||
|
free(this->presetError);
|
||||||
free(this);
|
free(this);
|
||||||
*pp = NULL;
|
*pp = NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user