Notification

From wiki
Revision as of 01:25, 27 June 2017 by DeamonHunter (Talk | contribs) (Initial commit.)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In Staxel, *.notification files are used to specify everything about notifications. These notifications are those small boxes that appear when something happens.

  • The size and look of the box
  • Sounds played, how long it stays up.
  • Whether multiple can be shown, and what translation code should they look for.

These notifications are often used alongside lines of code which change what the translation line is supposed to show.

Creating a *.notification file

Notifications actually don't use any other files, except Sound files, listed on this wiki. In essence a notification can be easily made, without the need to look up many other pages on this wiki. A full file might look like;

{
  "kind" : "staxel.notifications.general",
  "box" : "staxel/notifications/NotificationBox.png",
  "boxDimensions" : { "x" : 244.0, "y" : 82.5 },
  "displayTime" : 3000,
  "icon" : "",
  "translationCode" : "",
  "sticky" : false,
  "allowMultiple" : false,
  "soundEffect" : ""
}

Though if you want to simply copy the rest of the notifications in staxel, only the following would be needed;

{
  "__inherits" : "staxel/notifications/GeneralNotification.config",
  "code" : "staxel.notifications.AchievementUnlocked",
  "translationCode" : "achievements.achievementUnlocked",
  "icon" : "staxel/notifications/icons/AchievementIcon.png"
}

The code and icon properties should be fairly self explanatory. The translation code, however, leads to a line that you can use to Translate the line. You'll need to provide a language file in order to provide what text will actually shown. With all that you have a notification that can be displayed, and it will also show text as long as you have made a translation file for that.


Config Options

"code"

Valid options (String): A unique string which notification this object is.

Default Value: No default value is specified. Always need to provide your own.


A string containing the code of the notification the blob will be referring to.


"kind"

Valid options (String): A string representing what kind of notification this is.

Default Value: No default value is specified. Always need to provide your own.


A string that is used by Staxel to provide the correct information. Currently only two kinds are used; "staxel.notifications.general" the normal notification and "staxel.notifications.itemReceived" which is a notification for collecting items. In most cases the general kind is sufficient.


"icon"

Valid options (String): A string which contains the path to the an image.

Default Value: Can be omitted. Will not show an icon if omitted.


This is the image shown alongside the text to help contextualise the notification.


"box"

Valid options (String): A string which contains the path to the an image.

Default Value: No default value is specified. Always need to provide your own.


This is the image of the box shown underneath the text and image.


"boxDimensions"

Valid options (Vector 2): { "x" : 0.0, "y" : 0.0}

Default Value: No default value is specified. Always need to provide your own.


This specifies how large the box should be. This should be roughly the same size as the image used in the box property, but does not need to be.


"displayTime"

Valid options (Int): An int which contains the time in milliseconds.

Default Value: Can be omitted. Will show notification for 3 seconds if omitted.


This is how long the notification will show for.


"translationCode"

Valid options (String): A string which should not conflict with any other translation string

Default Value: Can be omitted. Will not show an text if omitted.


This is the code to the translation, that is the text, that should be shown on the notification.


"sticky"

Valid options (Bool): Either True or False

Default Value: Can be omitted. Will be False if omitted.


This determines whether or not the notification will stay up unless it is told to be hidden, probably via code.


"allowMultiple"

Valid options (Bool): Either True or False

Default Value: Can be omitted. Will be False if omitted.


This determines whether or not the notification will allow multiple copies of itself to show. Useful for notifications that might get spammed. (Like trying to sleep in a bed or buying something you can't buy.


"soundEffect"

Valid options (String): A string which points to a Sound code.

Default Value: Can be omitted. Will not play a sound if omitted.

This is the sound effect that the notification can play when it appears.