MODULE: Toaster 0.1.2

Started by eri0o, Wed 04/10/2023 03:32:49

Previous topic - Next topic

eri0o

toaster version 0.1.2

Get Latest Release toaster.scm | GitHub Repo | Download project .zip

This is a initial version of Toaster, a module to produce Toasts. These are those messages that appear on the screen and fade.

I will eventually write better docs and make the module more interesting, but here is a demo to explain what it does.



Usage

The basic usage is simply Toaster t; t.Toast("A Toast!");



Script API

Toaster

A toaster can produce toasts, but you can configure your toaster to produce different toasts as desired!

eToastColor Toaster.BackgroundColor
Background color of the toast, in AGS Color.

TextWindowGUI* Toaster.TextWindowGUI
You can set a TextWindowGUI to put the toast in a text box.

FontType Toaster.Font
The font to write the toast message.

eToastTweenEasingType Toaster.SlideInEasing
The easing to use when moving the toast into screen. These are the same possible ones in the tween module!

eToastTweenEasingType Toaster.SlideOutEasing
The easing to use when moving the toast out of existence

eToastAlignement Toaster.OriginAlignment
From where to position the toasts. It can be on the left, center and right.

float Toaster.Duration
How long in seconds should the Toast be on-screen.

float Toaster.Rotation
Rotation in degrees for produced toasts.

int Toaster.Icon
Add sprite to use as an icon in the left corner of the message.



License
This module is created by eri0o is provided with MIT License, see LICENSE for more details. It uses easing code based on Edmundo Ruiz and Robert Penner's, works, which are MIT and BSD licensed, respectively (and included in the module script).

AndreasBlack

I will try it soon, looks promising! (nod)

eri0o

Minimal update with added icon support!


Cassiebsg

And then some of us, eat toasts for breakfast. :D

There are those who believe that life here began out there...

AndreasBlack

Quote from: eri0o on Thu 05/10/2023 02:30:16Minimal update with added icon support!



Even better would be if you added the classic "steam look" bakground for the message! Perhaps Epic Games have their BG look and Gog. I rarely play games so i don't know, but steam seems to have that gradient blueish bakground everytime popping up so i printscreened it and used it as a joke in my demo game to make it look like you could get an achievement (laugh) But i think it's possible with real achievements in AGS games, right? Isn't there's a plugin for that? Perhaps it's already in there tho :-\

eri0o

If you are using one of the stores plugins that is already in the plugins. I don't think faking the style of a store is interesting (and one should really check the documentation, because my general feeling is this could get your game axed from using it, because you are pretending official notifications). But if one wants, it's possible to configure a Text GUI and pass it along, this will make the module draw a text box however it's configured in the editor, with each of the 9 pieces set.

AndreasBlack

I just like the gradient aesthetic. I use it for the controllers and for a notification where it says "push this to save anytime" aswell so it's not just for "fake steam achievement", but perhaps again you could still do that with the steam plugin, so never mind

eri0o

#7
@AndreasBlack I don't understand, but as I mentioned, if you configure this creating a Text Window GUI it will work, the gradient is just the background tile of the 9 pieces. See more details in the manual

https://adventuregamestudio.github.io/ags-manual/EditorGUI.html#customized-text-windows

Then you just pass it to the module.

I may alternatively create a way to pass a single sprite with the 9 in it (like a square) and some coordinates - need to think through which one would be needed for this.

My reasoning to implement it through Text Window GUI was in my mind people already would already have created the ones they use in their game for rendering dialogues and other messages, so there would be less work.

Edit: I realized that gradients look better if they are specifically draw because the height may change, but at the same time AGS has a slow pixel drawing API (I can't push a vertex to an Overlay, even though that would be sweet). But I may draw in a single line of pixels and then resize it in a second overlay - so hardware accelerated! But AGS uses 16-bit like colors for the API for drawing pixels... There is no "give a gradient from color a to b" in the surface API - which would be faster and happier approach. I may try to roll some magic here to have an alternative way to specify a gradient by code. Not sure how that will look like. I think I can smudge a gradient by hammering it on top of itself and varying the transparency. Will need to roll some magic for this...

AndreasBlack

#8
Probably you get confused cause i haven't tried it yet! I'm sorry i told you i should but i haven't. Working hard on a bakground for days. Perhaps i should take a break and try your module, but i'm so eager to finish stuff off so i can get somewhere in the game creation for once, and i just visit here for short breaks!

I'm sure it's good as it is. I didn't mean anything was wrong with it, or anything like that! My bad that i  communicate like a beep hole at times! (laugh) 

Another question btw. Does the Android Port work now with anything else then software renderer? Cause when i tried it only forced Software Renderer

eri0o

Erh, about android it depends on when is now and when is then. It should work now, but it should also have worked like an year ago. I don't remember things beyond this. :/

AndreasBlack

Sorry for the long delay! Been working on a giant BG (4000pixels wide) now i've tested 'The Toaster'. The syntax usages is a bit confusing for a none-coder like me, like you say perhaps write better documentation in the future. I didn't get how to tween it in fast, then stay on the screen for 5 seconds then tween out fast, sorta like the speed that is in your example, but just stay a little longer on the screen. Atm the duration also seems to adjust the animation speed itself i guess i must be doing something wrong, as always (laugh) This is my attempt code
 
Code: ags
Toaster t;
t.BackgroundColor=eToastColor_Aqua;
t.Duration=5.0;
t.Toast("Ps4 Connected");

SMF spam blocked by CleanTalk