FancyMenu [Fabric] [MOVED TO NEW PROJECT]

FancyMenu [Fabric] [MOVED TO NEW PROJECT]

17M Downloads

add a notification pop-up windows

duilehaojiu opened this issue ยท 4 comments

commented

Is there a way to add a notification pop-up function in the menu interface, so that the update logs and images of the mod package can be obtained and displayed through the server.

commented

You can already do that with a custom GUI + Text element with web source + Image element with web source.
For more information please join my Discord server.

commented

Please give more context on what exactly you want to do. I did not understand that request, sorry ๐Ÿ˜…

I think you could do this very easily with a datapack/command blocks rather than over-complicating it with FancyMenu. I've made a (very quick, possibly bad) example below:


Firstly, instead of having a 'Don't show again' checkbox, have two buttons: Close and Close and don't show again. Have their action scripts as follows:

Close:

  1. Close Screen
  2. Send Chat Message/Command with action value /trigger UpdateScreenOpen set 0

Close and don't show again:

  1. Close Screen
  2. Send Chat Message/Command with action value /trigger UpdateScreenOpen set 0
  3. Send Chat Message/Command with action value /trigger DontShowAgain set 1

Next, set up two scoreboards:

# Use trigger functions so the players can set their scores without needing OP permissions
scoreboard objectives add DontShowAgain trigger
scoreboard objectives add UpdateScreenOpen trigger

Then the following functions (I made them in data/update_screen/function):

new_update_released.mcfunction

# Remove and re-add the DontShowAgain scoreboard so that
# scores are reset for all players, even if they're offline
scoreboard objectives remove DontShowAgain
scoreboard objectives add DontShowAgain trigger

master.mcfunction

# Execute the command as the specific player
execute as @s run /
    # Don't show the screen if the player has already clicked 'Don't Show Again'
    execute unless score @s DontShowAgain matches 1 run /
        # Don't constantly run the show update screen function if the screen's already open!
        execute unless score @s UpdateScreenOpen matches 1 run /
            # Probably unnecessary, but Minecraft can be inconsistent when running commands as a specific player
            execute as @s run /
                # If the above pass, show the screen
                function update_screen:show_update_screen

show_update_screen.mcfunction

# Open the update screen (replace 'update_screen') with your GUI name
execute as @s run openguiscreen update_screen
# Record that the screen is open to prevent command being run repeatedly
execute as @s run scoreboard players set @s UpdateScreenOpen 1
# Re-enable UpdateScreenOpen trigger for the player
execute as @s run scoreboard players enable @s UpdateScreenOpen
# Re-enable DontShowAgain trigger for the player (probably unnecessary, but better to be safe)
execute as @s run scoreboard players enable @s DontShowAgain

Example Functions.zip


Finally, to make it work, you can either have a repeating command block with the command execute as @a run execute as @s run function update_screen:master, or if you're deploying the modpack for other people to run on their own servers then you can create the following file:

data/minecraft/tags/function/tick.json

{
  "values": [
    {
      "id": "update_screen:master",
      "required": false
    }
  ]
}

Then, when you've released an update, simply run function new_update_released to reset the DontShowAgain scoreboard, and the update screen GUI will open straight away for all online players, and for offline players it'll open the next time they connect.

Example Functions.zip

commented

Please give more context on what exactly you want to do. I did not understand that request, sorry ๐Ÿ˜…

commented

Please give more context on what exactly you want to do. I did not understand that request, sorry ๐Ÿ˜…

look like this
The images and text can be obtined from url
Image