Skip to content

Conversation

@BenCheung0422
Copy link
Member

@BenCheung0422 BenCheung0422 commented Nov 15, 2023

This feature is reserved for future use. This adds a support for in-app notifications, where toasts in the screen. It is different from in-game notifications, bare text only, as this includes a frame, and the color can be changed. This is important when there are some alerts, warnings and important information needed to notify the users.

I have several ideas about box popups and notifications: (fading is not supported right now)

  • Toast notifications (slide in slide out) - quick informative notification (near top-right/bottom-right corner sliding on side)
  • Bottom slide popup (slide in slide out) - app tool bar? But currently there is no such possible uses. (near bottom-right corner sliding on bottom)

Position for toasts may be configurable to upper or lower positions (also for each type of toast notification?).

Additionally, achievement unlocking toast is added to replace the text-only notifications regarding unlocking achievements. (https://discord.com/channels/280723930942013440/1141498209634623539)
This improves visual quality of life.

@BenCheung0422
Copy link
Member Author

BenCheung0422 commented Dec 30, 2023

Demo from #588:

Minicraft.Plus.2023-12-31.02-24-16.-.Trim.mp4

@Makkkkus
Copy link
Member

Makkkkus commented Jan 7, 2024

In-app notifications are usually a result of bad game design. Using this will make the game feel more like a cheap mobile game than an free and open-source sandbox game. Perhaps an icon can be showed insted when a controller is plugged in?

# Conflicts:
#	src/client/java/minicraft/item/FishingRodItem.java
#	src/client/java/minicraft/item/SummonItem.java
#	src/client/java/minicraft/screen/AchievementsDisplay.java
@BenCheung0422
Copy link
Member Author

New design for toast notifications

Minicraft.Plus.2024-02-09.11-48-17.mp4

@BenCheung0422
Copy link
Member Author

BenCheung0422 commented Feb 9, 2024

App status top bar (shows automatically for 2 seconds on startup and shown when "9" (I was seeking to use symbols but it seems like they are not supported, which is not rightActually it is possible, but with different wordings) is down)

Minicraft.Plus.2024-02-09.17-32-31.mp4

@BenCheung0422 BenCheung0422 changed the title Add support for in-app notifications Improved supports for in-app/game notifications and toasts Feb 9, 2024
@BenCheung0422
Copy link
Member Author

BenCheung0422 commented Feb 9, 2024

The new achievement unlocking toast, replacing the original text-only notification.

Minicraft.Plus.2024-02-09.19-37-49.mp4

@BenCheung0422
Copy link
Member Author

Updates has been made for this pull request regarding the issues and it is now ready for review again.

Copy link
Member

@Makkkkus Makkkkus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new changes look great!

Although, app toast and game toast should be merged to just be game toast. Having two is unneccecary.

@BenCheung0422
Copy link
Member Author

Ok, it is removed.

@Litorom
Copy link
Member

Litorom commented Jun 25, 2024

Can you update this please.

# Conflicts:
#	src/client/java/minicraft/core/Renderer.java
#	src/client/java/minicraft/screen/TutorialDisplayHandler.java
@BenCheung0422
Copy link
Member Author

Okay, branch updated.

Litorom and others added 2 commits June 27, 2024 17:00
# Conflicts:
#	src/client/java/minicraft/entity/furniture/DeathChest.java
@Makkkkus
Copy link
Member

Makkkkus commented Jun 3, 2025

This is a good addition to the game, but I still think that app toasts and game toasts should be merged. I don't see how they are substantially different.

Also, are you still working on this?

@BenCheung0422
Copy link
Member Author

I could still fix minor things for my pull requests on this repository, or else they could be closed.

@Makkkkus
Copy link
Member

Makkkkus commented Jun 3, 2025

I think at least this PR should be merged

Copy link
Member

@Makkkkus Makkkkus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still have some problems I wish you would adress.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances in-app notifications by introducing a new toast system with configurable positioning and upgraded visual styles, and it replaces the legacy notifications with in-game notifications.

  • Introduces AppToast with several frame implementations and configurable top/bottom positioning.
  • Implements AchievementUnlockToast for achievement notifications, replacing text-only alerts.
  • Updates various game logic files to use inGameNotifications and integrates toast management in the core update and render flows.

Reviewed Changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/client/java/minicraft/screen/AppToast.java New toast implementation supporting multiple frame styles and configurable positioning.
src/client/java/minicraft/screen/AchievementsDisplay.java Added AchievementUnlockToast and updated achievement notification logic.
src/client/java/minicraft/level/tile/*.java Replaced legacy notifications with inGameNotifications across wall, boss, and rock tiles.
src/client/java/minicraft/item/*.java Updated notification calls in item interactions to use inGameNotifications.
src/client/java/minicraft/core/Updater.java, Renderer.java, Game.java Integrated toast management and new in-game notifications with an app status bar.

protected int tick = 0;
protected int animationTick = 0; // 0 to ANIMATION_TIME, ANIMATION_TIME to 0

protected static abstract class ToastFrame {
Copy link
Member

@Makkkkus Makkkkus Jun 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the ToastFrame class as it is a single-variable class with no functionality that cannot be done in the Toast class. There is no need to create classes just for the fun of it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice


public static final AppStatusBar appStatusBar = new AppStatusBar();

public static class AppStatusBar {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps move the AppStatusBar and it's implementations into it's own file?

And variables are usually declared at the top of the class.

Copy link
Member Author

@BenCheung0422 BenCheung0422 Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not so sure about this since it is only used in Renderer and (ticked by) Updater.

this.status = status;
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think AppStatusBar, AppStatusElement and HardwareAccelerationElementStatus are similar enough to to be merged as a single class (similar to how the holding item bar at the bottom of the screen works).

Looking at how HARDWARE_ACCELERATION_STATUS is declared on the parent of the object it references, it would make more sense to create a struct with the data you want each icon to have, and then create instances of that struct when adding a new icon.

Blinking and all of that can be implemented in AppStatusBar, negating the need to call any other class. And System.getProperty("sun.java2d.opengl") doesn't necessarily need to be cached.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why you meant they are similar. Anyway, looking at this implementation is not sufficient. As an example, #588 added 2 new icons with more complex implementation details than this one.

Blinking is meaningful only for a particular one icon, thus not responsible for AppStatusBar to implement.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm proposing to move all functionality of this into the AppStatusBar class. Bringing in other pull requests into this is irrelevant.

Anything can be implemented in AppStatusBar, it's just a question if you are willing to cooperate and do such. Look at how other similar features are implemented (that you haven't designed).

protected int tick = 0;
protected int animationTick = 0; // 0 to ANIMATION_TIME, ANIMATION_TIME to 0

protected static abstract class ToastFrame {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice

}

public abstract class AppStatusElement {
public enum GeneralStatus {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a boolean.

Copy link
Member

@Makkkkus Makkkkus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very dissapointed with these changes.


@MagicConstant(intValues = {ACCELERATION_ON, ACCELERATION_OFF})
private int status = ACCELERATION_ON;
public class HardwareAccelerationElementStatus extends AppStatusElement<GeneralStatus> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this class.

OFF, ON
}

public abstract class AppStatusElement<E extends Enum<E>> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this class. It serves no purpose.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check further implementation than just a single usage with a minimal usage pattern. This API is designed to be extensible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't know if this will be extended yet. Minimal implementation is fine for most uses.

Copy link
Member Author

@BenCheung0422 BenCheung0422 Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still, this is a part of this API design.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this will not be extended, it is whole pointless to add this API; I would rather remove this feature from this pull request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed App Status Bar; #588 will be broken.

* Game Toasts are rendered only in gameplay and always located in the top-left corner without margin.
* The content of game toasts is implementation-specific.
*/
public abstract class GameToast extends Toast {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you add this class??

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To constrain and categorize to have only game toasts and app toasts more exactly. In design, it is not expected to see app toasts being in the list of game toasts, and game toasts are expected to behave similarly, different from app toasts in certain aspects.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already discussed this. You removed it. And now you're adding it back? Adding it is just a way of writing more code that does less. Adding code for the sake of adding code is pointless.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not removed it, but ignored it from the implementation to simplify the structure (in fact it should be specialized for the API). Also, adding design constrains preventing unexpected behaviors is an important thing for designing API.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good this is a game and not an API then

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.

3 participants