Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add a basic notification system #114

Merged
merged 13 commits into from
Jan 3, 2024

Conversation

SnazzyPanda
Copy link
Contributor

Adds a basic notification system to help us notify users of various errors, warnings, etc.

As part of this change, I had to bump the ImGui version to 1.90, and I have not fully re-tested the interface.

Some of the main changes include:

  • Adding a new file at Lampray/Control/lampNotification.h to provide functionality
  • Bumping the ImGui version to 1.90 to make use of recently added ChildWindow flags for auto-height resizing.
  • Fixing an issue with changing the font scale (the bug likely showed itself due to the ImGui update)
  • Added an error notification for when we fail to find the 7z.so file.

Usage

To add a notification for display, you would just need to include the Lampray/Control/lampNotification.h file and then call the related function with your notification message:

  • Lamp::Core::lampNotification::getInstance().pushErrorNotification("Error");
  • Lamp::Core::lampNotification::getInstance().pushInfoNotification("Info");
  • Lamp::Core::lampNotification::getInstance().pushWarningNotification("Warning");
  • Lamp::Core::lampNotification::getInstance().pushSuccessNotification("Success");
  • You could also use this function, where type is a string representation of the notification type ("info", "warning", "success", "error"):
    • Lamp::Core::lampNotification::getInstance().pushNotification("type", "message");

Currently, notifications only get displayed on the main modlist screen. To display them somewhere else, you would need to move or add Lamp::Core::lampNotification::getInstance().DisplayNotifications();. Perhaps in the future, we could also find some way to specify notification location (such as "top", "bottom", etc) to have multiple, separate notification areas.

The colors used are not currently user configurable, but should be exposed for modifying if needed.

I also implemented a word-wrapping function to try to support longer notification messages. I think it should work fine, but feel free to try to throw some stuff at it to make sure it holds up.

Here is an example of what this currently looks like:
notifs-1
In the screenshot, there are 2 info notifications ("Test Info" and a notification I was using to test longer strings with minimal spaces in them). The error notification at the bottom is showing a more standard message (with spaces throughout) that needs wrapping due to its length.

@CHollingworth
Copy link
Owner

How does the user dismiss notifications?

@SnazzyPanda
Copy link
Contributor Author

The get dismissed when the user clicks them.

@CHollingworth CHollingworth merged commit 3dc1c14 into CHollingworth:master Jan 3, 2024
2 checks passed
@SnazzyPanda SnazzyPanda deleted the issue-notification branch January 6, 2024 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants