Error notifications
This commit is contained in:
parent
776a39f0b3
commit
bedc3c94f8
@ -20,14 +20,13 @@ namespace gui
|
||||
namespace
|
||||
{
|
||||
utils::concurrency::container<std::vector<std::function<void()>>> on_frame_callbacks;
|
||||
utils::concurrency::container<std::vector<notification_t>> notifications;
|
||||
|
||||
ID3D11Device* device;
|
||||
ID3D11DeviceContext* device_context;
|
||||
bool initialized = false;
|
||||
bool toggled = false;
|
||||
|
||||
std::vector<notification_t> notifications;
|
||||
|
||||
void initialize_gui_context()
|
||||
{
|
||||
ImGui::CreateContext();
|
||||
@ -62,17 +61,19 @@ namespace gui
|
||||
|
||||
void show_notifications()
|
||||
{
|
||||
static auto window_flags = ImGuiWindowFlags_NoDecoration |
|
||||
ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoFocusOnAppearing |
|
||||
ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoMove;
|
||||
static auto window_flags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoSavedSettings |
|
||||
ImGuiWindowFlags_NoFocusOnAppearing | ImGuiWindowFlags_NoNav |
|
||||
ImGuiWindowFlags_NoMove;
|
||||
|
||||
notifications.access([](std::vector<notification_t>& notifications_)
|
||||
{
|
||||
auto index = 0;
|
||||
for (auto i = notifications.begin(); i != notifications.end(); ++i)
|
||||
for (auto i = notifications_.begin(); i != notifications_.end(); ++i)
|
||||
{
|
||||
const auto now = std::chrono::high_resolution_clock::now();
|
||||
if (now - i->creation_time >= i->duration)
|
||||
{
|
||||
notifications.erase(i--);
|
||||
notifications_.erase(i--);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -97,6 +98,7 @@ namespace gui
|
||||
|
||||
index++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void gui_draw()
|
||||
@ -231,7 +233,10 @@ namespace gui
|
||||
notification.duration = duration;
|
||||
notification.creation_time = std::chrono::high_resolution_clock::now();
|
||||
|
||||
notifications.insert(notifications.begin(), notification);
|
||||
notifications.access([notification](std::vector<notification_t>& notifications_)
|
||||
{
|
||||
notifications_.insert(notifications_.begin(), notification);
|
||||
});
|
||||
}
|
||||
|
||||
class component final : public component_interface
|
||||
|
@ -466,7 +466,6 @@ namespace entity_list
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -568,6 +567,7 @@ namespace entity_list
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
gui::notification("Error", utils::string::va("^1error setting field '%s'!", name.data()));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -589,6 +589,7 @@ namespace entity_list
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
gui::notification("Error", utils::string::va("^1error setting field '%s'!", name.data()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user